summaryrefslogtreecommitdiff
path: root/protocols/Telegram/tdlib/td/tdactor
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-06-04 19:24:05 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-06-04 19:24:05 +0300
commitefc336e60cf1331bf5f3213d296981b87b8b2a6c (patch)
treeea59ea1a324f45f6e8a06cc0887b376bfba90ca9 /protocols/Telegram/tdlib/td/tdactor
parent6e83622d2af1cec3c759f4cff6efe4df2fe3328c (diff)
fixes #3537 (Telegram: 32-разрядная версия падает в 64-разрядной Windows) + update to the fresh TDLIB
Diffstat (limited to 'protocols/Telegram/tdlib/td/tdactor')
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/example/example.cpp4
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/ConcurrentScheduler.cpp2
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/ConcurrentScheduler.h2
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/MultiPromise.cpp2
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/MultiPromise.h10
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/MultiTimeout.cpp33
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/MultiTimeout.h6
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/PromiseFuture.h22
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/SchedulerLocalStorage.h2
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/SignalSlot.h6
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/SleepActor.h2
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/Timeout.h2
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/actor.h2
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Actor-decl.h6
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Actor.h8
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorId-decl.h14
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorId.h2
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorInfo-decl.h8
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorInfo.h21
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Event.h4
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/impl/EventFull-decl.h2
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/impl/EventFull.h2
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Scheduler-decl.h19
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Scheduler.cpp4
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Scheduler.h37
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/test/actors_bugs.cpp2
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/test/actors_main.cpp2
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/test/actors_simple.cpp8
-rw-r--r--protocols/Telegram/tdlib/td/tdactor/test/actors_workers.cpp41
29 files changed, 140 insertions, 135 deletions
diff --git a/protocols/Telegram/tdlib/td/tdactor/example/example.cpp b/protocols/Telegram/tdlib/td/tdactor/example/example.cpp
index 8f182d8350..080df2baaa 100644
--- a/protocols/Telegram/tdlib/td/tdactor/example/example.cpp
+++ b/protocols/Telegram/tdlib/td/tdactor/example/example.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -13,7 +13,7 @@
class Worker final : public td::Actor {
public:
void ping(int x) {
- LOG(ERROR) << "Got ping " << x;
+ LOG(ERROR) << "Receive ping " << x;
}
};
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/ConcurrentScheduler.cpp b/protocols/Telegram/tdlib/td/tdactor/td/actor/ConcurrentScheduler.cpp
index 9a3cf21338..4eb8852c93 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/ConcurrentScheduler.cpp
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/ConcurrentScheduler.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/ConcurrentScheduler.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/ConcurrentScheduler.h
index 3f574de5ef..0158c945b6 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/ConcurrentScheduler.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/ConcurrentScheduler.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/MultiPromise.cpp b/protocols/Telegram/tdlib/td/tdactor/td/actor/MultiPromise.cpp
index f78e0f0161..5c53469084 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/MultiPromise.cpp
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/MultiPromise.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/MultiPromise.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/MultiPromise.h
index 73b24d5d1c..35636463be 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/MultiPromise.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/MultiPromise.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -107,10 +107,10 @@ class MultiPromiseActorSafe final : public MultiPromiseInterface {
size_t promise_count() const final;
explicit MultiPromiseActorSafe(string name) : multi_promise_(td::make_unique<MultiPromiseActor>(std::move(name))) {
}
- MultiPromiseActorSafe(const MultiPromiseActorSafe &other) = delete;
- MultiPromiseActorSafe &operator=(const MultiPromiseActorSafe &other) = delete;
- MultiPromiseActorSafe(MultiPromiseActorSafe &&other) = delete;
- MultiPromiseActorSafe &operator=(MultiPromiseActorSafe &&other) = delete;
+ MultiPromiseActorSafe(const MultiPromiseActorSafe &) = delete;
+ MultiPromiseActorSafe &operator=(const MultiPromiseActorSafe &) = delete;
+ MultiPromiseActorSafe(MultiPromiseActorSafe &&) = delete;
+ MultiPromiseActorSafe &operator=(MultiPromiseActorSafe &&) = delete;
~MultiPromiseActorSafe() final;
private:
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/MultiTimeout.cpp b/protocols/Telegram/tdlib/td/tdactor/td/actor/MultiTimeout.cpp
index 8c3dcb942f..56dedd461d 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/MultiTimeout.cpp
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/MultiTimeout.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -23,13 +23,13 @@ void MultiTimeout::set_timeout_at(int64 key, double timeout) {
bool need_update_timeout = heap_node->is_top();
timeout_queue_.fix(timeout, heap_node);
if (need_update_timeout || heap_node->is_top()) {
- update_timeout();
+ update_timeout("set_timeout");
}
} else {
CHECK(item.second);
timeout_queue_.insert(timeout, heap_node);
if (heap_node->is_top()) {
- update_timeout();
+ update_timeout("set_timeout 2");
}
}
}
@@ -44,12 +44,12 @@ void MultiTimeout::add_timeout_at(int64 key, double timeout) {
CHECK(item.second);
timeout_queue_.insert(timeout, heap_node);
if (heap_node->is_top()) {
- update_timeout();
+ update_timeout("add_timeout");
}
}
}
-void MultiTimeout::cancel_timeout(int64 key) {
+void MultiTimeout::cancel_timeout(int64 key, const char *source) {
LOG(DEBUG) << "Cancel " << get_name() << " for " << key;
auto item = items_.find(Item(key));
if (item != items_.end()) {
@@ -60,17 +60,26 @@ void MultiTimeout::cancel_timeout(int64 key) {
items_.erase(item);
if (need_update_timeout) {
- update_timeout();
+ update_timeout(source);
}
}
}
-void MultiTimeout::update_timeout() {
+void MultiTimeout::update_timeout(const char *source) {
if (items_.empty()) {
LOG(DEBUG) << "Cancel timeout of " << get_name();
- CHECK(timeout_queue_.empty());
- CHECK(Actor::has_timeout());
- Actor::cancel_timeout();
+ LOG_CHECK(timeout_queue_.empty()) << get_name() << ' ' << source;
+ if (!Actor::has_timeout()) {
+ bool has_pending_timeout = false;
+ for (auto &event : get_info()->mailbox_) {
+ if (event.type == Event::Type::Timeout) {
+ has_pending_timeout = true;
+ }
+ }
+ LOG_CHECK(has_pending_timeout) << get_name() << ' ' << get_info()->mailbox_.size() << ' ' << source;
+ } else {
+ Actor::cancel_timeout();
+ }
} else {
LOG(DEBUG) << "Set timeout of " << get_name() << " in " << timeout_queue_.top_key() - Time::now_cached();
Actor::set_timeout_at(timeout_queue_.top_key());
@@ -90,7 +99,7 @@ vector<int64> MultiTimeout::get_expired_keys(double now) {
void MultiTimeout::timeout_expired() {
vector<int64> expired_keys = get_expired_keys(Time::now_cached());
if (!items_.empty()) {
- update_timeout();
+ update_timeout("timeout_expired");
}
for (auto key : expired_keys) {
callback_(data_, key);
@@ -100,7 +109,7 @@ void MultiTimeout::timeout_expired() {
void MultiTimeout::run_all() {
vector<int64> expired_keys = get_expired_keys(Time::now_cached() + 1e10);
if (!expired_keys.empty()) {
- update_timeout();
+ update_timeout("run_all");
}
for (auto key : expired_keys) {
callback_(data_, key);
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/MultiTimeout.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/MultiTimeout.h
index 64803d346d..3c4b3d9e79 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/MultiTimeout.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/MultiTimeout.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -58,7 +58,7 @@ class MultiTimeout final : public Actor {
void add_timeout_at(int64 key, double timeout); // memcache semantics, doesn't replace old timeout
- void cancel_timeout(int64 key);
+ void cancel_timeout(int64 key, const char *source = "cancel_timeout");
void run_all();
@@ -71,7 +71,7 @@ class MultiTimeout final : public Actor {
KHeap<double> timeout_queue_;
std::set<Item> items_;
- void update_timeout();
+ void update_timeout(const char *source);
void timeout_expired() final;
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/PromiseFuture.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/PromiseFuture.h
index 5ddc6e9848..ff695f8d5d 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/PromiseFuture.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/PromiseFuture.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -30,10 +30,10 @@ class EventPromise final : public PromiseInterface<Unit> {
do_set_error();
}
- EventPromise(const EventPromise &other) = delete;
- EventPromise &operator=(const EventPromise &other) = delete;
- EventPromise(EventPromise &&other) = delete;
- EventPromise &operator=(EventPromise &&other) = delete;
+ EventPromise(const EventPromise &) = delete;
+ EventPromise &operator=(const EventPromise &) = delete;
+ EventPromise(EventPromise &&) = delete;
+ EventPromise &operator=(EventPromise &&) = delete;
~EventPromise() final {
do_set_error();
}
@@ -95,8 +95,8 @@ class PromiseActor final : public PromiseInterface<T> {
public:
PromiseActor() = default;
- PromiseActor(const PromiseActor &other) = delete;
- PromiseActor &operator=(const PromiseActor &other) = delete;
+ PromiseActor(const PromiseActor &) = delete;
+ PromiseActor &operator=(const PromiseActor &) = delete;
PromiseActor(PromiseActor &&) = default;
PromiseActor &operator=(PromiseActor &&) = default;
~PromiseActor() final {
@@ -156,11 +156,11 @@ class FutureActor final : public Actor {
FutureActor() = default;
- FutureActor(const FutureActor &other) = delete;
- FutureActor &operator=(const FutureActor &other) = delete;
+ FutureActor(const FutureActor &) = delete;
+ FutureActor &operator=(const FutureActor &) = delete;
- FutureActor(FutureActor &&other) = default;
- FutureActor &operator=(FutureActor &&other) = default;
+ FutureActor(FutureActor &&) = default;
+ FutureActor &operator=(FutureActor &&) = default;
~FutureActor() final = default;
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/SchedulerLocalStorage.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/SchedulerLocalStorage.h
index b89a283f74..d8236cf24d 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/SchedulerLocalStorage.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/SchedulerLocalStorage.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/SignalSlot.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/SignalSlot.h
index e1fd36323a..a0a6b5feaf 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/SignalSlot.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/SignalSlot.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -26,8 +26,8 @@ class Signal {
class Slot final : public Actor {
public:
Slot() = default;
- Slot(const Slot &other) = delete;
- Slot &operator=(const Slot &other) = delete;
+ Slot(const Slot &) = delete;
+ Slot &operator=(const Slot &) = delete;
Slot(Slot &&) = default;
Slot &operator=(Slot &&) = default;
~Slot() final {
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/SleepActor.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/SleepActor.h
index 8682ab0df5..e31a19eb9e 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/SleepActor.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/SleepActor.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/Timeout.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/Timeout.h
index cde72657b8..dd0be45741 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/Timeout.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/Timeout.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/actor.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/actor.h
index 0aed51710c..4b8f9c3c61 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/actor.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/actor.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Actor-decl.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Actor-decl.h
index b0e75bd21c..4aca52d8ab 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Actor-decl.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Actor-decl.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -79,10 +79,8 @@ class Actor : public ObserverBase {
std::shared_ptr<ActorContext> set_context(std::shared_ptr<ActorContext> context);
string set_tag(string tag);
- void always_wait_for_mailbox();
-
// for ActorInfo mostly
- void init(ObjectPool<ActorInfo>::OwnerPtr &&info);
+ void set_info(ObjectPool<ActorInfo>::OwnerPtr &&info);
ActorInfo *get_info();
const ActorInfo *get_info() const;
ObjectPool<ActorInfo>::OwnerPtr clear();
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Actor.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Actor.h
index d190a2158e..c3025646ab 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Actor.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Actor.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -110,7 +110,7 @@ inline string Actor::set_tag(string tag) {
return old_tag;
}
-inline void Actor::init(ObjectPool<ActorInfo>::OwnerPtr &&info) {
+inline void Actor::set_info(ObjectPool<ActorInfo>::OwnerPtr &&info) {
info_ = std::move(info);
}
@@ -164,8 +164,4 @@ inline Slice Actor::get_name() const {
return info_->get_name();
}
-inline void Actor::always_wait_for_mailbox() {
- info_->always_wait_for_mailbox();
-}
-
} // namespace td
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorId-decl.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorId-decl.h
index 2b60c72472..57bdee377e 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorId-decl.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorId-decl.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -23,8 +23,8 @@ class ActorId {
explicit ActorId(ObjectPool<ActorInfo>::WeakPtr ptr) : ptr_(ptr) {
}
ActorId() = default;
- ActorId(const ActorId &other) = default;
- ActorId &operator=(const ActorId &other) = default;
+ ActorId(const ActorId &) = default;
+ ActorId &operator=(const ActorId &) = default;
ActorId(ActorId &&other) noexcept : ptr_(other.ptr_) {
other.clear();
}
@@ -79,8 +79,8 @@ class ActorOwn {
ActorOwn &operator=(ActorOwn<OtherActorType> &&other);
ActorOwn(ActorOwn &&other) noexcept;
ActorOwn &operator=(ActorOwn &&other) noexcept;
- ActorOwn(const ActorOwn &other) = delete;
- ActorOwn &operator=(const ActorOwn &other) = delete;
+ ActorOwn(const ActorOwn &) = delete;
+ ActorOwn &operator=(const ActorOwn &) = delete;
~ActorOwn();
bool empty() const;
@@ -111,8 +111,8 @@ class ActorShared {
ActorShared &operator=(ActorShared<OtherActorType> &&other);
ActorShared(ActorShared &&other) noexcept;
ActorShared &operator=(ActorShared &&other) noexcept;
- ActorShared(const ActorShared &other) = delete;
- ActorShared &operator=(const ActorShared &other) = delete;
+ ActorShared(const ActorShared &) = delete;
+ ActorShared &operator=(const ActorShared &) = delete;
~ActorShared();
uint64 token() const;
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorId.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorId.h
index 76ef6d9a8b..c4446a62e6 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorId.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorId.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorInfo-decl.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorInfo-decl.h
index 3b9d3c2f2a..6726c0408d 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorInfo-decl.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorInfo-decl.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -108,17 +108,11 @@ class ActorInfo final
bool need_context() const;
bool need_start_up() const;
- void set_wait_generation(uint32 wait_generation);
- bool must_wait(uint32 wait_generation) const;
- void always_wait_for_mailbox();
-
private:
Deleter deleter_ = Deleter::None;
bool need_context_ = true;
bool need_start_up_ = true;
bool is_running_ = false;
- bool always_wait_for_mailbox_{false};
- uint32 wait_generation_{0};
std::atomic<int32> sched_id_{0};
Actor *actor_ = nullptr;
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorInfo.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorInfo.h
index 35ec31b168..a8e80342c9 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorInfo.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/ActorInfo.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -45,12 +45,11 @@ inline void ActorInfo::init(int32 sched_id, Slice name, ObjectPool<ActorInfo>::O
name_.assign(name.data(), name.size());
#endif
- actor_->init(std::move(this_ptr));
+ actor_->set_info(std::move(this_ptr));
deleter_ = deleter;
need_context_ = need_context;
need_start_up_ = need_start_up;
is_running_ = false;
- wait_generation_ = 0;
}
inline bool ActorInfo::need_context() const {
@@ -61,18 +60,6 @@ inline bool ActorInfo::need_start_up() const {
return need_start_up_;
}
-inline void ActorInfo::set_wait_generation(uint32 wait_generation) {
- wait_generation_ = wait_generation;
-}
-
-inline bool ActorInfo::must_wait(uint32 wait_generation) const {
- return wait_generation_ == wait_generation || (always_wait_for_mailbox_ && !mailbox_.empty());
-}
-
-inline void ActorInfo::always_wait_for_mailbox() {
- always_wait_for_mailbox_ = true;
-}
-
inline void ActorInfo::on_actor_moved(Actor *actor_new_ptr) {
actor_ = actor_new_ptr;
}
@@ -82,8 +69,8 @@ inline void ActorInfo::clear() {
CHECK(!actor_);
CHECK(!is_running());
CHECK(!is_migrating());
- // NB: must be in non migrating state
- // store invalid scheduler id.
+ // NB: must be in non-migrating state
+ // store invalid scheduler identifier
sched_id_.store((1 << 30) - 1, std::memory_order_relaxed);
VLOG(actor) << "Clear context " << context_.get() << " for " << get_name();
context_.reset();
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Event.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Event.h
index 2796c701e5..6f8976884c 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Event.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Event.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -155,7 +155,7 @@ class Event {
Event() : Event(Type::NoType) {
}
- Event(const Event &other) = delete;
+ Event(const Event &) = delete;
Event &operator=(const Event &) = delete;
Event(Event &&other) noexcept : type(other.type), link_token(other.link_token), data(other.data) {
other.type = Type::NoType;
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/EventFull-decl.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/EventFull-decl.h
index 4137765111..95c32343e8 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/EventFull-decl.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/EventFull-decl.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/EventFull.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/EventFull.h
index 89eabef768..450e355206 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/EventFull.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/EventFull.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Scheduler-decl.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Scheduler-decl.h
index 8ed9feb10a..4422795c91 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Scheduler-decl.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Scheduler-decl.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -39,17 +39,17 @@ extern int VERBOSITY_NAME(actor);
class ActorInfo;
-enum class ActorSendType { Immediate, Later, LaterWeak };
+enum class ActorSendType { Immediate, Later };
class Scheduler;
class SchedulerGuard {
public:
explicit SchedulerGuard(Scheduler *scheduler, bool lock = true);
~SchedulerGuard();
- SchedulerGuard(const SchedulerGuard &other) = delete;
- SchedulerGuard &operator=(const SchedulerGuard &other) = delete;
- SchedulerGuard(SchedulerGuard &&other) = default;
- SchedulerGuard &operator=(SchedulerGuard &&other) = delete;
+ SchedulerGuard(const SchedulerGuard &) = delete;
+ SchedulerGuard &operator=(const SchedulerGuard &) = delete;
+ SchedulerGuard(SchedulerGuard &&) = default;
+ SchedulerGuard &operator=(SchedulerGuard &&) = delete;
private:
MovableValue<bool> is_valid_ = true;
@@ -78,9 +78,7 @@ class Scheduler {
Scheduler &operator=(Scheduler &&) = delete;
~Scheduler();
- void init();
void init(int32 id, std::vector<std::shared_ptr<MpscPollableQueue<EventFull>>> outbound, Callback *callback);
- void clear();
int32 sched_id() const;
int32 sched_count() const;
@@ -172,6 +170,8 @@ class Scheduler {
};
friend class ServiceActor;
+ void clear();
+
void do_event(ActorInfo *actor, Event &&event);
void enter_actor(ActorInfo *actor_info);
@@ -200,8 +200,6 @@ class Scheduler {
template <ActorSendType send_type, class RunFuncT, class EventFuncT>
void send_impl(const ActorId<> &actor_id, const RunFuncT &run_func, const EventFuncT &event_func);
- void inc_wait_generation();
-
Timestamp run_timeout();
void run_mailbox();
Timestamp run_events(Timestamp timeout);
@@ -231,7 +229,6 @@ class Scheduler {
bool has_guard_ = false;
bool close_flag_ = false;
- uint32 wait_generation_ = 1;
int32 sched_id_ = 0;
int32 sched_n_ = 0;
std::shared_ptr<MpscPollableQueue<EventFull>> inbound_queue_;
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Scheduler.cpp b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Scheduler.cpp
index 38f2fc2e6f..64a1e14233 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Scheduler.cpp
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Scheduler.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -497,7 +497,6 @@ void Scheduler::run_mailbox() {
ListNode *node = actors_list.get();
CHECK(node);
auto actor_info = ActorInfo::from_list_node(node);
- inc_wait_generation();
flush_mailbox(actor_info, static_cast<void (*)(ActorInfo *)>(nullptr), static_cast<Event (*)()>(nullptr));
}
VLOG(actor) << "Run mailbox : finish " << actor_count_;
@@ -526,7 +525,6 @@ Timestamp Scheduler::run_timeout() {
while (!timeout_queue_.empty() && timeout_queue_.top_key() < now) {
HeapNode *node = timeout_queue_.pop();
ActorInfo *actor_info = ActorInfo::from_heap_node(node);
- inc_wait_generation();
send<ActorSendType::Immediate>(actor_info->actor_id(), Event::timeout());
}
return get_timeout();
diff --git a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Scheduler.h b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Scheduler.h
index d4d075785f..8c2b6d6e2a 100644
--- a/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Scheduler.h
+++ b/protocols/Telegram/tdlib/td/tdactor/td/actor/impl/Scheduler.h
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -34,10 +34,10 @@ class EventGuard {
return event_context_.flags == 0;
}
- EventGuard(const EventGuard &other) = delete;
- EventGuard &operator=(const EventGuard &other) = delete;
- EventGuard(EventGuard &&other) = delete;
- EventGuard &operator=(EventGuard &&other) = delete;
+ EventGuard(const EventGuard &) = delete;
+ EventGuard &operator=(const EventGuard &) = delete;
+ EventGuard(EventGuard &&) = delete;
+ EventGuard &operator=(EventGuard &&) = delete;
~EventGuard();
private:
@@ -58,10 +58,6 @@ inline SchedulerGuard Scheduler::get_const_guard() {
return SchedulerGuard(this, false);
}
-inline void Scheduler::init() {
- init(0, {}, nullptr);
-}
-
inline int32 Scheduler::sched_id() const {
return sched_id_;
}
@@ -110,12 +106,12 @@ ActorOwn<ActorT> Scheduler::register_actor_impl(Slice name, ActorT *actor_ptr, A
ActorId<ActorT> actor_id = weak_info->actor_id(actor_ptr);
if (sched_id != sched_id_) {
- send<ActorSendType::LaterWeak>(actor_id, Event::start());
+ send<ActorSendType::Later>(actor_id, Event::start());
do_migrate_actor(actor_info, sched_id);
} else {
pending_actors_list_.put(weak_info->get_list_node());
if (ActorTraits<ActorT>::need_start_up) {
- send<ActorSendType::LaterWeak>(actor_id, Event::start());
+ send<ActorSendType::Later>(actor_id, Event::start());
}
}
@@ -191,10 +187,6 @@ inline void Scheduler::before_tail_send(const ActorId<> &actor_id) {
// TODO
}
-inline void Scheduler::inc_wait_generation() {
- wait_generation_ += 2;
-}
-
template <ActorSendType send_type, class RunFuncT, class EventFuncT>
void Scheduler::send_impl(const ActorId<> &actor_id, const RunFuncT &run_func, const EventFuncT &event_func) {
ActorInfo *actor_info = actor_id.get_actor_info();
@@ -210,19 +202,12 @@ void Scheduler::send_impl(const ActorId<> &actor_id, const RunFuncT &run_func, c
CHECK(has_guard_ || !on_current_sched);
if (likely(send_type == ActorSendType::Immediate && on_current_sched && !actor_info->is_running() &&
- !actor_info->must_wait(wait_generation_))) { // run immediately
- if (likely(actor_info->mailbox_.empty())) {
- EventGuard guard(this, actor_info);
- run_func(actor_info);
- } else {
- flush_mailbox(actor_info, &run_func, &event_func);
- }
+ actor_info->mailbox_.empty())) { // run immediately
+ EventGuard guard(this, actor_info);
+ run_func(actor_info);
} else {
if (on_current_sched) {
add_to_mailbox(actor_info, event_func());
- if (send_type == ActorSendType::Later) {
- actor_info->set_wait_generation(wait_generation_);
- }
} else {
send_to_scheduler(actor_sched_id, actor_id, event_func());
}
@@ -283,7 +268,7 @@ inline void Scheduler::yield_actor(Actor *actor) {
yield_actor(actor->get_info());
}
inline void Scheduler::yield_actor(ActorInfo *actor_info) {
- send<ActorSendType::LaterWeak>(actor_info->actor_id(), Event::yield());
+ send<ActorSendType::Later>(actor_info->actor_id(), Event::yield());
}
inline void Scheduler::stop_actor(Actor *actor) {
diff --git a/protocols/Telegram/tdlib/td/tdactor/test/actors_bugs.cpp b/protocols/Telegram/tdlib/td/tdactor/test/actors_bugs.cpp
index 0720f0ed6f..d5b0ce0f26 100644
--- a/protocols/Telegram/tdlib/td/tdactor/test/actors_bugs.cpp
+++ b/protocols/Telegram/tdlib/td/tdactor/test/actors_bugs.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/tdactor/test/actors_main.cpp b/protocols/Telegram/tdlib/td/tdactor/test/actors_main.cpp
index 628b74a94c..9042d7e0ce 100644
--- a/protocols/Telegram/tdlib/td/tdactor/test/actors_main.cpp
+++ b/protocols/Telegram/tdlib/td/tdactor/test/actors_main.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/protocols/Telegram/tdlib/td/tdactor/test/actors_simple.cpp b/protocols/Telegram/tdlib/td/tdactor/test/actors_simple.cpp
index 78d32d5437..e01b356e52 100644
--- a/protocols/Telegram/tdlib/td/tdactor/test/actors_simple.cpp
+++ b/protocols/Telegram/tdlib/td/tdactor/test/actors_simple.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -15,6 +15,7 @@
#include "td/utils/MpscPollableQueue.h"
#include "td/utils/Observer.h"
#include "td/utils/port/FileFd.h"
+#include "td/utils/port/path.h"
#include "td/utils/port/thread.h"
#include "td/utils/Promise.h"
#include "td/utils/Slice.h"
@@ -281,8 +282,9 @@ class OpenClose final : public td::Actor {
}
void wakeup() final {
auto observer = reinterpret_cast<td::ObserverBase *>(123);
+ td::CSlice file_name = "server";
if (cnt_ > 0) {
- auto r_file_fd = td::FileFd::open("server", td::FileFd::Read | td::FileFd::Create);
+ auto r_file_fd = td::FileFd::open(file_name, td::FileFd::Read | td::FileFd::Create);
LOG_CHECK(r_file_fd.is_ok()) << r_file_fd.error();
auto file_fd = r_file_fd.move_as_ok();
{ auto pollable_fd = file_fd.get_poll_info().extract_pollable_fd(observer); }
@@ -290,6 +292,7 @@ class OpenClose final : public td::Actor {
cnt_--;
yield();
} else {
+ td::unlink(file_name).ignore();
td::Scheduler::instance()->finish();
}
}
@@ -571,7 +574,6 @@ TEST(Actors, stop_in_teardown) {
class AlwaysWaitForMailbox final : public td::Actor {
public:
void start_up() final {
- always_wait_for_mailbox();
td::create_actor<td::SleepActor>("Sleep", 0.1,
td::PromiseCreator::lambda([actor_id = actor_id(this), ptr = this](td::Unit) {
td::send_closure(actor_id, &AlwaysWaitForMailbox::g);
diff --git a/protocols/Telegram/tdlib/td/tdactor/test/actors_workers.cpp b/protocols/Telegram/tdlib/td/tdactor/test/actors_workers.cpp
index bac42e3fd5..720aa2fe87 100644
--- a/protocols/Telegram/tdlib/td/tdactor/test/actors_workers.cpp
+++ b/protocols/Telegram/tdlib/td/tdactor/test/actors_workers.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -10,6 +10,7 @@
#include "td/utils/common.h"
#include "td/utils/SliceBuilder.h"
#include "td/utils/tests.h"
+#include "td/utils/Time.h"
class PowerWorker final : public td::Actor {
public:
@@ -147,3 +148,41 @@ TEST(Actors, workers_small_query_two_threads) {
TEST(Actors, workers_small_query_nine_threads) {
test_workers(9, 10, 10000, 1);
}
+
+class SenderActor;
+
+class ReceiverActor final : public td::Actor {
+ public:
+ void receive(td::ActorId<SenderActor>) {
+ }
+};
+
+class SenderActor final : public td::Actor {
+ public:
+ explicit SenderActor(td::ActorId<ReceiverActor> actor_id) : actor_id_(std::move(actor_id)) {
+ }
+
+ private:
+ td::ActorId<ReceiverActor> actor_id_;
+
+ void loop() final {
+ for (int i = 0; i < 10000; i++) {
+ send_closure(actor_id_, &ReceiverActor::receive, actor_id(this));
+ }
+ set_timeout_in(0.001);
+ }
+};
+
+TEST(Actors, send_closure_while_finish) {
+ td::ConcurrentScheduler sched(1, 0);
+
+ auto receiver = sched.create_actor_unsafe<ReceiverActor>(0, "ReceiverActor").release();
+ sched.create_actor_unsafe<SenderActor>(1, "SenderActor", receiver).release();
+
+ sched.start();
+ auto end_time = td::Time::now() + 0.2;
+ while (td::Time::now() < end_time) {
+ sched.run_main(0.1);
+ }
+ sched.finish();
+}