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 ()
 
void lock ()
 
void unlock ()
 
 spin_mutex ()
 
 ~spin_mutex ()
 
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 ( )

Definition at line 130 of file threads_none.h.

130 {}

◆ spin_mutex() [2/4]

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

Definition at line 88 of file threads_pthread.h.

References ulock.

88 { ulock = OS_UNFAIR_LOCK_INIT; }

◆ ~spin_mutex() [1/3]

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

Definition at line 89 of file threads_pthread.h.

89 {}

◆ spin_mutex() [3/4]

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

Definition at line 116 of file threads_pthread.h.

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

◆ ~spin_mutex() [2/3]

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

Definition at line 117 of file threads_pthread.h.

117 {}

◆ spin_mutex() [4/4]

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

Definition at line 146 of file threads_pthread.h.

References slock.

146 { pthread_spin_init(&slock, PTHREAD_PROCESS_PRIVATE); }

◆ ~spin_mutex() [3/3]

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

Definition at line 147 of file threads_pthread.h.

References slock.

147 { pthread_spin_destroy(&slock); }

Member Function Documentation

◆ lock() [1/4]

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

Definition at line 91 of file threads_pthread.h.

References ulock.

91 { os_unfair_lock_lock(&ulock); }

◆ lock() [2/4]

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

Definition at line 119 of file threads_pthread.h.

References slock.

119 { OSSpinLockLock(&slock); }

◆ lock() [3/4]

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

◆ lock() [4/4]

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

Definition at line 149 of file threads_pthread.h.

References slock.

149 { pthread_spin_lock(&slock); }

◆ unlock() [1/4]

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

Definition at line 92 of file threads_pthread.h.

References ulock.

92 { os_unfair_lock_unlock(&ulock); }

◆ unlock() [2/4]

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

Definition at line 120 of file threads_pthread.h.

References slock.

120 { OSSpinLockUnlock(&slock); }

◆ unlock() [3/4]

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

Definition at line 132 of file threads_none.h.

Referenced by libMesh::Threads::spin_mutex::scoped_lock::release().

132 {}

◆ unlock() [4/4]

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

Definition at line 150 of file threads_pthread.h.

References slock.

150 { pthread_spin_unlock(&slock); }

Member Data Documentation

◆ slock [1/2]

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

Definition at line 138 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 168 of file threads_pthread.h.

◆ ulock

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

Definition at line 110 of file threads_pthread.h.

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


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