libcopp  1.2.1
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 ()
 
void lock ()
 
void unlock ()
 
bool is_locked ()
 
bool try_lock ()
 
bool try_unlock ()
 

Private Types

enum  lock_state_t { UNLOCKED = 0, LOCKED = 1 }
 

Private Attributes

::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 166 of file spin_lock.h.

Member Enumeration Documentation

Enumerator
UNLOCKED 
LOCKED 

Definition at line 168 of file spin_lock.h.

Constructor & Destructor Documentation

util::lock::spin_lock::spin_lock ( )
inline

Definition at line 179 of file spin_lock.h.

References lock_status_, util::lock::atomic_int_type< Ty >::store(), and UNLOCKED.

Member Function Documentation

bool util::lock::spin_lock::is_locked ( )
inline
void util::lock::spin_lock::lock ( )
inline
bool util::lock::spin_lock::try_lock ( )
inline
bool util::lock::spin_lock::try_unlock ( )
inline
void util::lock::spin_lock::unlock ( )
inline

Field Documentation

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

Definition at line 176 of file spin_lock.h.

Referenced by is_locked(), lock(), spin_lock(), try_lock(), try_unlock(), and unlock().


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