blob: 3ba36dacea84603cd5cfbf52358b81fb303c348d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include "hack.h"
#include <library/cpp/deprecated/atomic/atomic.h>
#include <util/system/spin_wait.h>
#include "spinlock.h"
void SPIN_L(spinlock_t* l) {
if (!AtomicTryLock(l)) {
TSpinWait sw;
while (!AtomicTryAndTryLock(l)) {
sw.Sleep();
}
}
}
void SPIN_U(spinlock_t* l) {
AtomicUnlock(l);
}
|