/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
library/cpp/messagebus/cc_semaphore.h
36 строк
615 B
qkrorlqr
Initial NBS OpenSource export
28 апр 2023, 21:54
28 апр 2023, 21:54
783a858
Код
Авторство
О чём код?
#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); } };