diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/messagebus/actor/tasks.h | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/messagebus/actor/tasks.h')
-rw-r--r-- | library/cpp/messagebus/actor/tasks.h | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/library/cpp/messagebus/actor/tasks.h b/library/cpp/messagebus/actor/tasks.h index 31d35931d2..e3b3f0f504 100644 --- a/library/cpp/messagebus/actor/tasks.h +++ b/library/cpp/messagebus/actor/tasks.h @@ -4,45 +4,45 @@ #include <util/system/yassert.h> namespace NActor { - class TTasks { - enum { - // order of values is important - E_WAITING, - E_RUNNING_NO_TASKS, - E_RUNNING_GOT_TASKS, - }; - - private: - TAtomic State; - - public: - TTasks() - : State(E_WAITING) - { + class TTasks { + enum { + // order of values is important + E_WAITING, + E_RUNNING_NO_TASKS, + E_RUNNING_GOT_TASKS, + }; + + private: + TAtomic State; + + public: + TTasks() + : State(E_WAITING) + { } - // @return true iff caller have to either schedule task or execute it - bool AddTask() { - // High contention case optimization: AtomicGet is cheaper than AtomicSwap. - if (E_RUNNING_GOT_TASKS == AtomicGet(State)) { - return false; - } + // @return true iff caller have to either schedule task or execute it + bool AddTask() { + // High contention case optimization: AtomicGet is cheaper than AtomicSwap. + if (E_RUNNING_GOT_TASKS == AtomicGet(State)) { + return false; + } - TAtomicBase oldState = AtomicSwap(&State, E_RUNNING_GOT_TASKS); - return oldState == E_WAITING; + TAtomicBase oldState = AtomicSwap(&State, E_RUNNING_GOT_TASKS); + return oldState == E_WAITING; } - // called by executor - // @return true iff we have to recheck queues - bool FetchTask() { - TAtomicBase newState = AtomicDecrement(State); - if (newState == E_RUNNING_NO_TASKS) { - return true; - } else if (newState == E_WAITING) { - return false; - } - Y_FAIL("unknown"); - } - }; - -} + // called by executor + // @return true iff we have to recheck queues + bool FetchTask() { + TAtomicBase newState = AtomicDecrement(State); + if (newState == E_RUNNING_NO_TASKS) { + return true; + } else if (newState == E_WAITING) { + return false; + } + Y_FAIL("unknown"); + } + }; + +} |