1#ifndef NE_STL_INCLUDENE_STL_SPINLOCK_H
2#define NE_STL_INCLUDENE_STL_SPINLOCK_H
8#define NE_STL_SPINLOCK_USE_THRD_YIELD 1
9#if (NE_STL_SPINLOCK_USE_THRD_YIELD)
11#if defined(NE_STL_USE_MSVC)
13#include <thr/xthreads.h>
20#define THRD_YIELD() _Thrd_yield()
22#if defined(NE_STL_OS_ANDROID) || defined(NE_STL_OS_LINUX)
24#define THRD_YIELD() sched_yield()
28#define THRD_YIELD() pthread_yield_np()
38enum class lock_state : int32_t { lock_state_begin, lock_state_unlocked, lock_state_locked, lock_state_end };
40struct lock_locked :
integral_constant<int32_t, static_cast<int32_t>(lock_state::lock_state_locked)> {};
41struct lock_unlocked :
integral_constant<int32_t, static_cast<int32_t>(lock_state::lock_state_unlocked)> {};
47 :
value_{lock_unlocked::value} {}
Definition: ne_stl_spinlock.h:61
_lock_guard(spinlock &lock)
Definition: ne_stl_spinlock.h:63
_lock_guard & operator=(const _lock_guard &other)=delete
~_lock_guard()
Definition: ne_stl_spinlock.h:67
nstd::spinlock & lock_
Definition: ne_stl_spinlock.h:71
Definition: ne_stl_spinlock.h:44
nstd::atomic_int value_
Definition: ne_stl_spinlock.h:57
void lock()
Definition: ne_stl_spinlock.h:48
_spinlock & operator=(const _spinlock &other)=delete
_spinlock()
Definition: ne_stl_spinlock.h:46
void unlock()
Definition: ne_stl_spinlock.h:53
bool compare_exchange(const T expected_val, const T new_val)
Definition: ne_stl_atomic.h:161
void store(const T new_val)
Definition: ne_stl_atomic.h:174
Definition: ne_stl_any.h:7
_integral_constant< T, _value > integral_constant
Definition: ne_stl_type_traits.h:15
#define THRD_YIELD()
Definition: ne_stl_spinlock.h:28