diff options
author | nga <[email protected]> | 2022-02-10 16:48:09 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:48:09 +0300 |
commit | 1f553f46fb4f3c5eec631352cdd900a0709016af (patch) | |
tree | a231fba2c03b440becaea6c86a2702d0bfb0336e /library/cpp/messagebus/cc_semaphore.h | |
parent | c4de7efdedc25b49cbea74bd589eecb61b55b60a (diff) |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/messagebus/cc_semaphore.h')
-rw-r--r-- | library/cpp/messagebus/cc_semaphore.h | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/library/cpp/messagebus/cc_semaphore.h b/library/cpp/messagebus/cc_semaphore.h index 0df8a3d664e..17d3b3bf323 100644 --- a/library/cpp/messagebus/cc_semaphore.h +++ b/library/cpp/messagebus/cc_semaphore.h @@ -1,36 +1,36 @@ -#pragma once - -#include "latch.h" - -template <typename TThis> -class TComplexConditionSemaphore { -private: - TLatch Latch; - -public: - void Updated() { - if (GetThis()->TryWait()) { - Latch.Unlock(); - } - } - - void Wait() { - while (!GetThis()->TryWait()) { - Latch.Lock(); - if (GetThis()->TryWait()) { - Latch.Unlock(); - return; - } - Latch.Wait(); - } - } - +#pragma once + +#include "latch.h" + +template <typename TThis> +class TComplexConditionSemaphore { +private: + TLatch Latch; + +public: + void Updated() { + if (GetThis()->TryWait()) { + Latch.Unlock(); + } + } + + void Wait() { + while (!GetThis()->TryWait()) { + Latch.Lock(); + if (GetThis()->TryWait()) { + Latch.Unlock(); + return; + } + Latch.Wait(); + } + } + bool IsLocked() { return Latch.IsLocked(); } - -private: - TThis* GetThis() { - return static_cast<TThis*>(this); - } -}; + +private: + TThis* GetThis() { + return static_cast<TThis*>(this); + } +}; |