diff --git a/benchmark/bench_actor.cpp b/benchmark/bench_actor.cpp index adc57d05..9e88999a 100644 --- a/benchmark/bench_actor.cpp +++ b/benchmark/bench_actor.cpp @@ -136,7 +136,7 @@ class QueryBench : public td::Benchmark { virtual ~Callback() = default; virtual void on_result(int x) = 0; }; - explicit ClientActor(std::unique_ptr callback) : callback_(std::move(callback)) { + explicit ClientActor(td::unique_ptr callback) : callback_(std::move(callback)) { } void f(int x) { callback_->on_result(x * x); @@ -152,7 +152,7 @@ class QueryBench : public td::Benchmark { } private: - std::unique_ptr callback_; + td::unique_ptr callback_; }; class ServerActor : public td::Actor { diff --git a/benchmark/bench_db.cpp b/benchmark/bench_db.cpp index e43ab917..954222ed 100644 --- a/benchmark/bench_db.cpp +++ b/benchmark/bench_db.cpp @@ -167,13 +167,13 @@ class SqliteKeyValueAsyncBench : public td::Benchmark { } private: - std::unique_ptr scheduler_; + td::unique_ptr scheduler_; std::shared_ptr sql_connection_; std::shared_ptr sqlite_kv_safe_; - std::unique_ptr sqlite_kv_async_; + td::unique_ptr sqlite_kv_async_; td::Status do_start_up() { - scheduler_ = std::make_unique(); + scheduler_ = td::make_unique(); scheduler_->init(1); auto guard = scheduler_->get_main_guard(); diff --git a/benchmark/bench_tddb.cpp b/benchmark/bench_tddb.cpp index 3a776934..2b110126 100644 --- a/benchmark/bench_tddb.cpp +++ b/benchmark/bench_tddb.cpp @@ -76,13 +76,13 @@ class MessagesDbBench : public Benchmark { } private: - std::unique_ptr scheduler_; + td::unique_ptr scheduler_; std::shared_ptr sql_connection_; std::shared_ptr messages_db_sync_safe_; std::shared_ptr messages_db_async_; Status do_start_up() { - scheduler_ = std::make_unique(); + scheduler_ = make_unique(); scheduler_->init(1); auto guard = scheduler_->get_main_guard(); diff --git a/benchmark/wget.cpp b/benchmark/wget.cpp index 850c5b64..0103d7f1 100644 --- a/benchmark/wget.cpp +++ b/benchmark/wget.cpp @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) { auto timeout = 10; auto ttl = 3; auto prefer_ipv6 = (argc > 2 && std::string(argv[2]) == "-6"); - auto scheduler = std::make_unique(); + auto scheduler = td::make_unique(); scheduler->init(0); scheduler ->create_actor_unsafe(0, "Client", td::PromiseCreator::lambda([](td::Result res) { diff --git a/example/cpp/td_example.cpp b/example/cpp/td_example.cpp index e155226d..14a5f3c4 100644 --- a/example/cpp/td_example.cpp +++ b/example/cpp/td_example.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/td/mtproto/HandshakeActor.cpp b/td/mtproto/HandshakeActor.cpp index a3ea97e4..1ca40bd2 100644 --- a/td/mtproto/HandshakeActor.cpp +++ b/td/mtproto/HandshakeActor.cpp @@ -5,6 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include "td/mtproto/HandshakeActor.h" + #include "td/mtproto/HandshakeConnection.h" #include "td/utils/common.h" @@ -13,14 +14,12 @@ namespace td { namespace mtproto { -HandshakeActor::HandshakeActor(std::unique_ptr handshake, - std::unique_ptr raw_connection, - std::unique_ptr context, double timeout, - Promise> raw_connection_promise, - Promise> handshake_promise) +HandshakeActor::HandshakeActor(unique_ptr handshake, unique_ptr raw_connection, + unique_ptr context, double timeout, + Promise> raw_connection_promise, + Promise> handshake_promise) : handshake_(std::move(handshake)) - , connection_( - std::make_unique(std::move(raw_connection), handshake_.get(), std::move(context))) + , connection_(make_unique(std::move(raw_connection), handshake_.get(), std::move(context))) , timeout_(timeout) , raw_connection_promise_(std::move(raw_connection_promise)) , handshake_promise_(std::move(handshake_promise)) { diff --git a/td/mtproto/HandshakeActor.h b/td/mtproto/HandshakeActor.h index b5a02490..af53cf82 100644 --- a/td/mtproto/HandshakeActor.h +++ b/td/mtproto/HandshakeActor.h @@ -13,26 +13,28 @@ namespace td { namespace mtproto { + class AuthKeyHandshake; class AuthKeyHandshakeContext; class RawConnection; class HandshakeConnection; + // Has Raw connection. Generates new auth key. And returns it and raw_connection. Or error... class HandshakeActor : public Actor { public: - HandshakeActor(std::unique_ptr handshake, std::unique_ptr raw_connection, - std::unique_ptr context, double timeout, - Promise> raw_connection_promise, - Promise> handshake_promise); + HandshakeActor(unique_ptr handshake, unique_ptr raw_connection, + unique_ptr context, double timeout, + Promise> raw_connection_promise, + Promise> handshake_promise); void close(); private: - std::unique_ptr handshake_; - std::unique_ptr connection_; + unique_ptr handshake_; + unique_ptr connection_; double timeout_; - Promise> raw_connection_promise_; - Promise> handshake_promise_; + Promise> raw_connection_promise_; + Promise> handshake_promise_; void start_up() override; void tear_down() override { diff --git a/td/mtproto/HandshakeConnection.h b/td/mtproto/HandshakeConnection.h index f01f52e3..c5e3bf8e 100644 --- a/td/mtproto/HandshakeConnection.h +++ b/td/mtproto/HandshakeConnection.h @@ -26,8 +26,8 @@ class HandshakeConnection : private RawConnection::Callback , private AuthKeyHandshake::Callback { public: - HandshakeConnection(std::unique_ptr raw_connection, AuthKeyHandshake *handshake, - std::unique_ptr context) + HandshakeConnection(unique_ptr raw_connection, AuthKeyHandshake *handshake, + unique_ptr context) : raw_connection_(std::move(raw_connection)), handshake_(handshake), context_(std::move(context)) { handshake_->resume(this); } @@ -36,7 +36,7 @@ class HandshakeConnection return raw_connection_->get_poll_info(); } - std::unique_ptr move_as_raw_connection() { + unique_ptr move_as_raw_connection() { return std::move(raw_connection_); } @@ -54,9 +54,9 @@ class HandshakeConnection } private: - std::unique_ptr raw_connection_; + unique_ptr raw_connection_; AuthKeyHandshake *handshake_; - std::unique_ptr context_; + unique_ptr context_; void send_no_crypto(const Storer &storer) override { raw_connection_->send_no_crypto(PacketStorer(0, storer)); diff --git a/td/mtproto/IStreamTransport.cpp b/td/mtproto/IStreamTransport.cpp index 71bafc8b..f4a5cd74 100644 --- a/td/mtproto/IStreamTransport.cpp +++ b/td/mtproto/IStreamTransport.cpp @@ -13,14 +13,14 @@ namespace td { namespace mtproto { -std::unique_ptr create_transport(TransportType type) { +unique_ptr create_transport(TransportType type) { switch (type.type) { case TransportType::ObfuscatedTcp: - return std::make_unique(type.dc_id, std::move(type.secret)); + return td::make_unique(type.dc_id, std::move(type.secret)); case TransportType::Tcp: - return std::make_unique(); + return td::make_unique(); case TransportType::Http: - return std::make_unique(type.secret); + return td::make_unique(type.secret); } UNREACHABLE(); } diff --git a/td/mtproto/IStreamTransport.h b/td/mtproto/IStreamTransport.h index c38ab4e0..9b262030 100644 --- a/td/mtproto/IStreamTransport.h +++ b/td/mtproto/IStreamTransport.h @@ -34,6 +34,6 @@ class IStreamTransport { virtual TransportType get_type() const = 0; }; -std::unique_ptr create_transport(TransportType type); +unique_ptr create_transport(TransportType type); } // namespace mtproto } // namespace td diff --git a/td/mtproto/PingConnection.h b/td/mtproto/PingConnection.h index c880066f..68bbfb05 100644 --- a/td/mtproto/PingConnection.h +++ b/td/mtproto/PingConnection.h @@ -24,7 +24,7 @@ namespace mtproto { class PingConnection : private RawConnection::Callback { public: - PingConnection(std::unique_ptr raw_connection, size_t ping_count) + PingConnection(unique_ptr raw_connection, size_t ping_count) : raw_connection_(std::move(raw_connection)), ping_count_(ping_count) { } @@ -32,7 +32,7 @@ class PingConnection : private RawConnection::Callback { return raw_connection_->get_poll_info(); } - std::unique_ptr move_as_raw_connection() { + unique_ptr move_as_raw_connection() { return std::move(raw_connection_); } @@ -76,7 +76,7 @@ class PingConnection : private RawConnection::Callback { } private: - std::unique_ptr raw_connection_; + unique_ptr raw_connection_; size_t ping_count_ = 1; double start_time_ = 0.0; double finish_time_ = 0.0; diff --git a/td/mtproto/RawConnection.h b/td/mtproto/RawConnection.h index 39ba72ca..1e4572c2 100644 --- a/td/mtproto/RawConnection.h +++ b/td/mtproto/RawConnection.h @@ -42,7 +42,7 @@ class RawConnection { virtual void on_mtproto_error() = 0; }; RawConnection() = default; - RawConnection(SocketFd socket_fd, TransportType transport_type, std::unique_ptr stats_callback) + RawConnection(SocketFd socket_fd, TransportType transport_type, unique_ptr stats_callback) : socket_fd_(std::move(socket_fd)) , transport_(create_transport(transport_type)) , stats_callback_(std::move(stats_callback)) { @@ -116,7 +116,7 @@ class RawConnection { std::map quick_ack_to_token_; bool has_error_{false}; - std::unique_ptr stats_callback_; + unique_ptr stats_callback_; StateManager::ConnectionToken connection_token_; diff --git a/td/mtproto/SessionConnection.cpp b/td/mtproto/SessionConnection.cpp index 432f7688..a12b924e 100644 --- a/td/mtproto/SessionConnection.cpp +++ b/td/mtproto/SessionConnection.cpp @@ -659,7 +659,7 @@ Status SessionConnection::on_quick_ack(uint64 quick_ack_token) { callback_->on_message_ack(quick_ack_token); return Status::OK(); } -SessionConnection::SessionConnection(Mode mode, std::unique_ptr raw_connection, AuthData *auth_data, +SessionConnection::SessionConnection(Mode mode, unique_ptr raw_connection, AuthData *auth_data, DhCallback *dh_callback) : raw_connection_(std::move(raw_connection)), auth_data_(auth_data), dh_callback_(dh_callback) { state_ = Init; diff --git a/td/mtproto/SessionConnection.h b/td/mtproto/SessionConnection.h index 07bfa351..b5c965b0 100644 --- a/td/mtproto/SessionConnection.h +++ b/td/mtproto/SessionConnection.h @@ -66,8 +66,7 @@ class SessionConnection , private RawConnection::Callback { public: enum class Mode { Tcp, Http, HttpLongPoll }; - SessionConnection(Mode mode, std::unique_ptr raw_connection, AuthData *auth_data, - DhCallback *dh_callback); + SessionConnection(Mode mode, unique_ptr raw_connection, AuthData *auth_data, DhCallback *dh_callback); PollableFdInfo &get_poll_info(); @@ -181,7 +180,7 @@ class SessionConnection int64 main_message_id_ = 0; double created_at_ = 0; - std::unique_ptr raw_connection_; + unique_ptr raw_connection_; AuthData *auth_data_; SessionConnection::Callback *callback_ = nullptr; DhCallback *dh_callback_; diff --git a/td/telegram/AnimationsManager.cpp b/td/telegram/AnimationsManager.cpp index 66107372..6c7cd307 100644 --- a/td/telegram/AnimationsManager.cpp +++ b/td/telegram/AnimationsManager.cpp @@ -129,7 +129,7 @@ tl_object_ptr AnimationsManager::get_animation_object(FileId td_->file_manager_->get_file_object(file_id)); } -FileId AnimationsManager::on_get_animation(std::unique_ptr new_animation, bool replace) { +FileId AnimationsManager::on_get_animation(unique_ptr new_animation, bool replace) { auto file_id = new_animation->file_id; LOG(INFO) << (replace ? "Replace" : "Add") << " animation " << file_id << " of size " << new_animation->dimensions; auto &a = animations_[file_id]; @@ -200,7 +200,7 @@ FileId AnimationsManager::dup_animation(FileId new_id, FileId old_id) { CHECK(old_animation != nullptr); auto &new_animation = animations_[new_id]; CHECK(!new_animation); - new_animation = std::make_unique(*old_animation); + new_animation = make_unique(*old_animation); new_animation->file_id = new_id; new_animation->thumbnail.file_id = td_->file_manager_->dup_file_id(new_animation->thumbnail.file_id); return new_id; diff --git a/td/telegram/AnimationsManager.h b/td/telegram/AnimationsManager.h index 64657c14..8f43f833 100644 --- a/td/telegram/AnimationsManager.h +++ b/td/telegram/AnimationsManager.h @@ -99,7 +99,7 @@ class AnimationsManager : public Actor { const Animation *get_animation(FileId file_id) const; - FileId on_get_animation(std::unique_ptr new_animation, bool replace); + FileId on_get_animation(unique_ptr new_animation, bool replace); int32 get_saved_animations_hash(const char *source) const; diff --git a/td/telegram/AudiosManager.cpp b/td/telegram/AudiosManager.cpp index 37536d5d..e8fbd09d 100644 --- a/td/telegram/AudiosManager.cpp +++ b/td/telegram/AudiosManager.cpp @@ -43,7 +43,7 @@ tl_object_ptr AudiosManager::get_audio_object(FileId file_id) { get_photo_size_object(td_->file_manager_.get(), &audio->thumbnail), td_->file_manager_->get_file_object(file_id)); } -FileId AudiosManager::on_get_audio(std::unique_ptr