diff options
author | George Hazan <ghazan@miranda.im> | 2022-11-30 17:48:47 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-11-30 17:48:47 +0300 |
commit | 0ece30dc7c0e34b4c5911969b8fa99c33c6d023c (patch) | |
tree | 671325d3fec09b999411e4e3ab84ef8259261818 /protocols/Telegram/tdlib/td/tdactor/example | |
parent | 46c53ffc6809c67e4607e99951a2846c382b63b2 (diff) |
Telegram: update for TDLIB
Diffstat (limited to 'protocols/Telegram/tdlib/td/tdactor/example')
-rw-r--r-- | protocols/Telegram/tdlib/td/tdactor/example/example.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/protocols/Telegram/tdlib/td/tdactor/example/example.cpp b/protocols/Telegram/tdlib/td/tdactor/example/example.cpp index 4c2415c5e2..8f182d8350 100644 --- a/protocols/Telegram/tdlib/td/tdactor/example/example.cpp +++ b/protocols/Telegram/tdlib/td/tdactor/example/example.cpp @@ -1,31 +1,33 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // 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) // #include "td/actor/actor.h" +#include "td/actor/ConcurrentScheduler.h" #include "td/utils/logging.h" +#include "td/utils/Time.h" -class Worker : public td::Actor { +class Worker final : public td::Actor { public: void ping(int x) { - LOG(ERROR) << "got ping " << x; + LOG(ERROR) << "Got ping " << x; } }; -class MainActor : public td::Actor { +class MainActor final : public td::Actor { public: - void start_up() override { - LOG(ERROR) << "start up"; + void start_up() final { + LOG(ERROR) << "Start up"; set_timeout_in(10); worker_ = td::create_actor_on_scheduler<Worker>("Worker", 1); send_closure(worker_, &Worker::ping, 123); } - void timeout_expired() override { - LOG(ERROR) << "timeout expired"; + void timeout_expired() final { + LOG(ERROR) << "Timeout expired"; td::Scheduler::instance()->finish(); } @@ -33,17 +35,15 @@ class MainActor : public td::Actor { td::ActorOwn<Worker> worker_; }; -int main(void) { - td::ConcurrentScheduler scheduler; - scheduler.init(4 /*threads_count*/); +int main() { + td::ConcurrentScheduler scheduler(4 /*thread_count*/, 0); scheduler.start(); { - auto guard = scheduler.get_current_guard(); + auto guard = scheduler.get_main_guard(); td::create_actor_on_scheduler<MainActor>("Main actor", 0).release(); } while (!scheduler.is_finished()) { - scheduler.run_main(10); + scheduler.run_main(td::Timestamp::in(10)); } scheduler.finish(); - return 0; } |