blob: 9f214e1ce13b8b21f2075de94d53fbe528ca432c (
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
45
46
47
48
49
50
51
|
#include "fork_aware_rw_spin_lock.h"
#include "at_fork.h"
namespace NYT::NThreading {
////////////////////////////////////////////////////////////////////////////////
void TForkAwareReaderWriterSpinLock::AcquireReader() noexcept
{
GetForkLock()->AcquireReaderForkFriendly();
SpinLock_.AcquireReader();
}
void TForkAwareReaderWriterSpinLock::ReleaseReader() noexcept
{
SpinLock_.ReleaseReader();
GetForkLock()->ReleaseReader();
}
void TForkAwareReaderWriterSpinLock::AcquireWriter() noexcept
{
GetForkLock()->AcquireReaderForkFriendly();
SpinLock_.AcquireWriter();
}
void TForkAwareReaderWriterSpinLock::ReleaseWriter() noexcept
{
SpinLock_.ReleaseWriter();
GetForkLock()->ReleaseReader();
}
bool TForkAwareReaderWriterSpinLock::IsLocked() const noexcept
{
return SpinLock_.IsLocked();
}
bool TForkAwareReaderWriterSpinLock::IsLockedByReader() const noexcept
{
return SpinLock_.IsLockedByReader();
}
bool TForkAwareReaderWriterSpinLock::IsLockedByWriter() const noexcept
{
return SpinLock_.IsLockedByWriter();
}
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT::NThreading
|