blob: b1edf55cd60c10fdcc856f42e3ca7e3259eafc8e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#pragma once
#include "cc_semaphore.h"
#include <library/cpp/deprecated/atomic/atomic.h>
#include <util/generic/noncopyable.h>
namespace NBus {
namespace NPrivate {
class TRemoteServerSessionSemaphore: public TComplexConditionSemaphore<TRemoteServerSessionSemaphore> {
private:
const char* const Name;
TAtomicBase const LimitCount;
TAtomicBase const LimitSize;
TAtomic CurrentCount;
TAtomic CurrentSize;
TAtomic PausedByUser;
TAtomic StopSignal;
public:
TRemoteServerSessionSemaphore(TAtomicBase limitCount, TAtomicBase limitSize, const char* name = "unnamed");
~TRemoteServerSessionSemaphore();
TAtomicBase GetCurrentCount() const {
return AtomicGet(CurrentCount);
}
TAtomicBase GetCurrentSize() const {
return AtomicGet(CurrentSize);
}
void IncrementMultiple(TAtomicBase count, TAtomicBase size);
bool TryWait();
void ReleaseMultiple(TAtomicBase count, TAtomicBase size);
void Stop();
void PauseByUsed(bool pause);
private:
void CheckNeedToUnlock();
};
}
}
|