InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IDThreading::spin_mutex Class Reference

#include <IDThreading.h>

Public Member Functions

void lock ()
 
bool try_lock ()
 
void unlock ()
 

Detailed Description

spin_mutex is the fastest mutex. It occupies a single byte and it is non-recursive. It should be used only for locking short critical sections (less than 20 CPU instructions). This type of mutex is not fair and does not scale well under contention.

Member Function Documentation

void IDThreading::spin_mutex::lock ()

Blocks the current thread until ownership of the mutex can be obtained for the calling thread. PRECONDITION: the calling thread must not already have ownership of this mutex object.

bool IDThreading::spin_mutex::try_lock ()

Attempts to obtain the ownership of the mutex for the calling thread without blocking. If ownership is not obtained, there is no effect and try_lock immediately returns false. If the ownership is obtained the call will return true.

void IDThreading::spin_mutex::unlock ()

Releases the calling thread's ownership of the mutex. PRECONDITION: The calling thread must own this mutex, otherwise behavior is undefined.