blob: f8127ae45f8617e8a65707d8dbbc1ebb23c2707c (
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
|
#include "hot_swap.h"
#include <util/system/spinlock.h>
namespace NHotSwapPrivate {
void TWriterLock::Acquire() noexcept {
AtomicIncrement(ReadersCount);
}
void TWriterLock::Release() noexcept {
AtomicDecrement(ReadersCount);
}
void TWriterLock::WaitAllReaders() const noexcept {
TAtomicBase cnt = AtomicGet(ReadersCount);
while (cnt > 0) {
SpinLockPause();
cnt = AtomicGet(ReadersCount);
Y_ASSERT(cnt >= 0);
}
}
}
|