From 2009d58f6a77ea0d895b6ae1b246bc9c976f45b1 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 27 Aug 2020 01:27:34 +0300 Subject: [PATCH] Deprecate ActorShared with 0 token. GitOrigin-RevId: 15dc5e63afa4c0d08f911101eaa78513df6aebc5 --- td/telegram/ConfigManager.cpp | 4 ++-- tdactor/td/actor/SignalSlot.h | 2 +- tdactor/td/actor/impl/Actor-decl.h | 1 - tdactor/td/actor/impl/Actor.h | 5 ++--- tdactor/test/actors_main.cpp | 4 ++-- tdactor/test/actors_simple.cpp | 2 +- test/mtproto.cpp | 2 +- 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index c8dae2040..23bd09036 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -1055,7 +1055,7 @@ void ConfigManager::request_config_from_dc_impl(DcId dc_id) { config_sent_cnt_++; auto query = G()->net_query_creator().create_unauth(telegram_api::help_getConfig(), dc_id); query->total_timeout_limit_ = 60 * 60 * 24; - G()->net_query_dispatcher().dispatch_with_callback(std::move(query), actor_shared(this, 0)); + G()->net_query_dispatcher().dispatch_with_callback(std::move(query), actor_shared(this, 8)); } void ConfigManager::do_set_ignore_sensitive_content_restrictions(bool ignore_sensitive_content_restrictions) { @@ -1276,7 +1276,7 @@ void ConfigManager::on_result(NetQueryPtr res) { return; } - CHECK(token == 0); + CHECK(token == 8); CHECK(config_sent_cnt_ > 0); config_sent_cnt_--; auto r_config = fetch_result(std::move(res)); diff --git a/tdactor/td/actor/SignalSlot.h b/tdactor/td/actor/SignalSlot.h index e7cc7e162..6159c9f88 100644 --- a/tdactor/td/actor/SignalSlot.h +++ b/tdactor/td/actor/SignalSlot.h @@ -72,7 +72,7 @@ class Slot final : public Actor { } ActorShared<> get_signal_new() { register_if_empty(); - return actor_shared(); + return actor_shared(this); } private: diff --git a/tdactor/td/actor/impl/Actor-decl.h b/tdactor/td/actor/impl/Actor-decl.h index c750ac1fb..129fcda52 100644 --- a/tdactor/td/actor/impl/Actor-decl.h +++ b/tdactor/td/actor/impl/Actor-decl.h @@ -101,7 +101,6 @@ class Actor : public ObserverBase { template ActorId actor_id(SelfT *self); - ActorShared<> actor_shared(); template ActorShared actor_shared(SelfT *self, uint64 id = static_cast(-1)); diff --git a/tdactor/td/actor/impl/Actor.h b/tdactor/td/actor/impl/Actor.h index fd78012af..cd709ce60 100644 --- a/tdactor/td/actor/impl/Actor.h +++ b/tdactor/td/actor/impl/Actor.h @@ -125,12 +125,11 @@ ActorId Actor::actor_id(SelfT *self) { return ActorId(info_.get_weak()); } -inline ActorShared<> Actor::actor_shared() { - return actor_shared(this); -} template ActorShared Actor::actor_shared(SelfT *self, uint64 id) { CHECK(static_cast(self) == this); + // TODO replace with CHECK + LOG_IF(ERROR, id == 0) << "ActorShared with token 0 must not be created"; return ActorShared(actor_id(self), id); } diff --git a/tdactor/test/actors_main.cpp b/tdactor/test/actors_main.cpp index a26236967..f9f085361 100644 --- a/tdactor/test/actors_main.cpp +++ b/tdactor/test/actors_main.cpp @@ -353,7 +353,7 @@ class SendToDead : public Actor { set_timeout_in(Random::fast_uint32() % 3 * 0.001); if (ttl_ != 0) { child_ = create_actor_on_scheduler( - "Child", Random::fast_uint32() % Scheduler::instance()->sched_count(), actor_shared(), ttl_ - 1); + "Child", Random::fast_uint32() % Scheduler::instance()->sched_count(), actor_shared(this), ttl_ - 1); } } void timeout_expired() override { @@ -376,7 +376,7 @@ class SendToDead : public Actor { ActorShared<> create_reference() { ref_cnt_++; - return actor_shared(); + return actor_shared(this); } void hangup_shared() override { ref_cnt_--; diff --git a/tdactor/test/actors_simple.cpp b/tdactor/test/actors_simple.cpp index 4204d60ee..709a8bc65 100644 --- a/tdactor/test/actors_simple.cpp +++ b/tdactor/test/actors_simple.cpp @@ -482,7 +482,7 @@ class LaterMasterActor : public Actor { std::vector> children_; void start_up() override { for (int i = 0; i < cnt_; i++) { - children_.push_back(create_actor("B", actor_shared())); + children_.push_back(create_actor("B", actor_shared(this))); } yield(); } diff --git a/test/mtproto.cpp b/test/mtproto.cpp index 9651b2c67..b7c528e6e 100644 --- a/test/mtproto.cpp +++ b/test/mtproto.cpp @@ -459,7 +459,7 @@ class Socks5TestActor : public Actor { return promise.set_error(Status::Error(PSTRING() << "Failed to open socket: " << r_socket.error())); } create_actor("socks5", r_socket.move_as_ok(), mtproto_ip_address, "", "", - make_unique(std::move(promise)), actor_shared()) + make_unique(std::move(promise)), actor_shared(this)) .release(); }