libcopp  2.2.0
Public Member Functions | Private Types | Private Attributes
util::lock::spin_lock Class Reference

自旋锁 More...

#include <spin_lock.h>

Collaboration diagram for util::lock::spin_lock:
Collaboration graph

Public Member Functions

 spin_lock () noexcept
 
void lock () noexcept
 
void unlock () noexcept
 
bool is_locked () noexcept
 
bool try_lock () noexcept
 
bool try_unlock () noexcept
 

Private Types

enum  lock_state_t { UNLOCKED = 0 , LOCKED = 1 }
 

Private Attributes

LIBCOPP_COPP_NAMESPACE_ID::util::lock::atomic_int_type< unsigned int > lock_status_
 

Detailed Description

自旋锁

See also
http://www.boost.org/doc/libs/1_61_0/doc/html/atomic/usage_examples.html#boost_atomic.usage_examples.example_spinlock

Definition at line 197 of file spin_lock.h.

Member Enumeration Documentation

◆ lock_state_t

Enumerator
UNLOCKED 
LOCKED 

Definition at line 199 of file spin_lock.h.

Constructor & Destructor Documentation

◆ spin_lock()

util::lock::spin_lock::spin_lock ( )
inlinenoexcept

Definition at line 210 of file spin_lock.h.

Member Function Documentation

◆ is_locked()

bool util::lock::spin_lock::is_locked ( )
inlinenoexcept

Definition at line 224 of file spin_lock.h.

References util::lock::memory_order_acquire.

◆ lock()

void util::lock::spin_lock::lock ( )
inlinenoexcept

◆ try_lock()

bool util::lock::spin_lock::try_lock ( )
inlinenoexcept

Definition at line 228 of file spin_lock.h.

References util::lock::memory_order_acq_rel.

◆ try_unlock()

bool util::lock::spin_lock::try_unlock ( )
inlinenoexcept

Definition at line 233 of file spin_lock.h.

References util::lock::memory_order_acq_rel.

◆ unlock()

void util::lock::spin_lock::unlock ( )
inlinenoexcept

Definition at line 219 of file spin_lock.h.

References util::lock::memory_order_release.

Field Documentation

◆ lock_status_

LIBCOPP_COPP_NAMESPACE_ID::util::lock::atomic_int_type< unsigned int > util::lock::spin_lock::lock_status_
private

Definition at line 207 of file spin_lock.h.


The documentation for this class was generated from the following file: