#pragma once #include "cc_semaphore.h" #include #include #include #include namespace NBus { namespace NPrivate { class TRemoteClientSessionSemaphore: public TComplexConditionSemaphore { private: const char* const Name; TAtomicBase const Limit; TAtomic Current; TAtomic StopSignal; public: TRemoteClientSessionSemaphore(TAtomicBase limit, const char* name = "unnamed"); ~TRemoteClientSessionSemaphore(); TAtomicBase GetCurrent() const { return AtomicGet(Current); } void Acquire(); bool TryAcquire(); void Increment(); void IncrementMultiple(TAtomicBase count); bool TryWait(); void Release(); void ReleaseMultiple(TAtomicBase count); void Stop(); private: void CheckNeedToUnlock(); }; } }