aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/threading/spin_wait_hook.h
blob: 4c120fbfaed023286ef73914fbf5747638cedf6b (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
#pragma once

#include <library/cpp/yt/cpu_clock/clock.h>

#include <library/cpp/yt/misc/enum.h>

#include <util/system/src_location.h>

namespace NYT::NThreading {

////////////////////////////////////////////////////////////////////////////////

DEFINE_ENUM(ESpinLockActivityKind,
    (Read)
    (Write)
    (ReadWrite)
);

using TSpinWaitSlowPathHook = void(*)(
    TCpuDuration cpuDelay,
    const ::TSourceLocation& location,
    ESpinLockActivityKind activityKind);

void RegisterSpinWaitSlowPathHook(TSpinWaitSlowPathHook hook);
void InvokeSpinWaitSlowPathHooks(
    TCpuDuration cpuDelay,
    const ::TSourceLocation& location,
    ESpinLockActivityKind activityKind);

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT::NThreading