libMesh
Classes | Public Member Functions | Private Attributes | List of all members
libMesh::Threads::spin_mutex Class Reference

Spin mutex. More...

#include <threads_none.h>

Classes

class  scoped_lock
 

Public Member Functions

 spin_mutex ()
 
void lock ()
 
void unlock ()
 
 spin_mutex ()
 
 ~spin_mutex ()=default
 
void lock ()
 
void unlock ()
 
 spin_mutex ()
 
 ~spin_mutex ()=default
 
void lock ()
 
void unlock ()
 
 spin_mutex ()
 
 ~spin_mutex ()
 
void lock ()
 
void unlock ()
 

Private Attributes

os_unfair_lock ulock
 
OSSpinLock slock
 
pthread_spinlock_t slock
 

Detailed Description

Spin mutex.

Implements mutual exclusion by busy-waiting in user space for the lock to be acquired.

Definition at line 127 of file threads_none.h.

Constructor & Destructor Documentation

◆ spin_mutex() [1/4]

libMesh::Threads::spin_mutex::spin_mutex ( )
inline

Definition at line 130 of file threads_none.h.

130 {}

◆ spin_mutex() [2/4]

libMesh::Threads::spin_mutex::spin_mutex ( )
inline

Definition at line 87 of file threads_pthread.h.

References ulock.

87 { ulock = OS_UNFAIR_LOCK_INIT; }

◆ ~spin_mutex() [1/3]

libMesh::Threads::spin_mutex::~spin_mutex ( )
default

◆ spin_mutex() [3/4]

libMesh::Threads::spin_mutex::spin_mutex ( )
inline

Definition at line 115 of file threads_pthread.h.

115 : slock(0) {} // The convention is that the lock being zero is _unlocked_

◆ ~spin_mutex() [2/3]

libMesh::Threads::spin_mutex::~spin_mutex ( )
default

◆ spin_mutex() [4/4]

libMesh::Threads::spin_mutex::spin_mutex ( )
inline

Definition at line 145 of file threads_pthread.h.

References slock.

145 { pthread_spin_init(&slock, PTHREAD_PROCESS_PRIVATE); }

◆ ~spin_mutex() [3/3]

libMesh::Threads::spin_mutex::~spin_mutex ( )
inline

Definition at line 146 of file threads_pthread.h.

References slock.

146 { pthread_spin_destroy(&slock); }

Member Function Documentation

◆ lock() [1/4]

void libMesh::Threads::spin_mutex::lock ( )
inline

Definition at line 90 of file threads_pthread.h.

References ulock.

90 { os_unfair_lock_lock(&ulock); }

◆ lock() [2/4]

void libMesh::Threads::spin_mutex::lock ( )
inline

Definition at line 118 of file threads_pthread.h.

References slock.

118 { OSSpinLockLock(&slock); }

◆ lock() [3/4]

void libMesh::Threads::spin_mutex::lock ( )
inline

◆ lock() [4/4]

void libMesh::Threads::spin_mutex::lock ( )
inline

Definition at line 148 of file threads_pthread.h.

References slock.

148 { pthread_spin_lock(&slock); }

◆ unlock() [1/4]

void libMesh::Threads::spin_mutex::unlock ( )
inline

Definition at line 91 of file threads_pthread.h.

References ulock.

91 { os_unfair_lock_unlock(&ulock); }

◆ unlock() [2/4]

void libMesh::Threads::spin_mutex::unlock ( )
inline

Definition at line 119 of file threads_pthread.h.

References slock.

119 { OSSpinLockUnlock(&slock); }

◆ unlock() [3/4]

void libMesh::Threads::spin_mutex::unlock ( )
inline

◆ unlock() [4/4]

void libMesh::Threads::spin_mutex::unlock ( )
inline

Definition at line 149 of file threads_pthread.h.

References slock.

149 { pthread_spin_unlock(&slock); }

Member Data Documentation

◆ slock [1/2]

OSSpinLock libMesh::Threads::spin_mutex::slock
private

Definition at line 137 of file threads_pthread.h.

Referenced by lock(), spin_mutex(), unlock(), and ~spin_mutex().

◆ slock [2/2]

pthread_spinlock_t libMesh::Threads::spin_mutex::slock
private

Definition at line 167 of file threads_pthread.h.

◆ ulock

os_unfair_lock libMesh::Threads::spin_mutex::ulock
private

Definition at line 109 of file threads_pthread.h.

Referenced by lock(), spin_mutex(), and unlock().


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