diff options
| author | levlam <levlam@telegram.org> | 2021-11-03 15:10:43 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2021-11-03 15:10:43 +0300 |
| commit | 6a5b0506e51fdbdb91d70d2c579da37058fda930 (patch) | |
| tree | 35902d38122657a959db586ca2564f71d6bc9115 /benchmark | |
| parent | ffa48e523a0f5e9730d11df70638e895728a01cf (diff) | |
Split Actor.is_lite to need_context and need_start_up.
Diffstat (limited to 'benchmark')
| -rw-r--r-- | benchmark/bench_actor.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/benchmark/bench_actor.cpp b/benchmark/bench_actor.cpp index bfcaa65a7..338442c62 100644 --- a/benchmark/bench_actor.cpp +++ b/benchmark/bench_actor.cpp @@ -18,24 +18,33 @@ #pragma comment(linker, "/STACK:16777216") #endif -class CreateActorBench final : public td::Benchmark { - private: - td::ConcurrentScheduler scheduler_; +struct TestActor final : public td::Actor { + static td::int32 actor_count_; - struct TestActor final : public td::Actor { - static td::int32 actor_count_; + void start_up() final { + actor_count_++; + stop(); + } - void start_up() final { - actor_count_++; - stop(); + void tear_down() final { + if (--actor_count_ == 0) { + td::Scheduler::instance()->finish(); } + } +}; - void tear_down() final { - if (--actor_count_ == 0) { - td::Scheduler::instance()->finish(); - } - } - }; +td::int32 TestActor::actor_count_; + +template <> +class td::ActorTraits<TestActor> { + public: + static constexpr bool need_context = false; + static constexpr bool need_start_up = true; +}; + +class CreateActorBench final : public td::Benchmark { + private: + td::ConcurrentScheduler scheduler_; void start_up() final { scheduler_.init(0); @@ -61,8 +70,6 @@ class CreateActorBench final : public td::Benchmark { } }; -td::int32 CreateActorBench::TestActor::actor_count_; - template <int type> class RingBench final : public td::Benchmark { public: |
