blob: b1670e92d4ad62db47f60fa4959997513f1f0ce3 (
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
|
#include "spin_lock_count.h"
#include <library/cpp/yt/assert/assert.h>
#include <library/cpp/yt/misc/tls.h>
#include <util/system/types.h>
namespace NYT::NThreading::NPrivate {
#ifndef NDEBUG
////////////////////////////////////////////////////////////////////////////////
YT_DEFINE_THREAD_LOCAL(i64, ActiveSpinLockCount, 0);
////////////////////////////////////////////////////////////////////////////////
void RecordSpinLockAcquired(bool isAcquired)
{
if (isAcquired) {
ActiveSpinLockCount()++;
}
}
void RecordSpinLockReleased()
{
YT_VERIFY(ActiveSpinLockCount() > 0);
ActiveSpinLockCount()--;
}
void VerifyNoSpinLockAffinity()
{
YT_VERIFY(ActiveSpinLockCount() == 0);
}
#endif
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT::NThreading::NPrivate
|