aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/c-ares/src/lib/atomic.cpp
blob: 9f02620121668d981c46d87049f19d10988fab28 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <library/cpp/deprecated/atomic/atomic.h>
#include <util/system/spin_wait.h>

#include "atomic.h"

EXTERN_C void acquire_lock(atomic_t *lock)
{
    if (!AtomicTryLock(lock)) {
        TSpinWait sw;

        while (!AtomicTryAndTryLock(lock)) {
            sw.Sleep();
        }
    }
}

EXTERN_C void release_lock(atomic_t *lock)
{
    AtomicUnlock(lock);
}