class::sys::Mutex

class sys::Mutex
  : public api::WorkObject

This class holds a Mutex used with multi-threaded applications.

Summary

Mutex()

Mutex(

const MutexAttributes & attr
)

int lock()

int lock_timed(

const chrono::ClockTime & clock_time
)

Mutex & operator<<(

const MutexAttributes & a
)

int set_attributes(

const MutexAttributes & attr
)

int try_lock()

int unlock()

Members

Mutex()

Constructs a Mutex with the default settings.


Mutex(

const MutexAttributes & attr
)

Constructs a Mutex using the specified attributes.


int lock()

Attempts to lock the mutex.

If the mutex is locked by another thread, the thread will block until the mutex becomes available.

If the thread already holds a lock on the mutex, it will

  • increment the count if the mutex is recursive, or
  • return less than zero and set errno to EDEADLK

int lock_timed(

const chrono::ClockTime & clock_time
)

Attempts to lock the mutex but times out after the specified duration.

Parameters

  • clock_time A clock time object that defines the maximum amount of time to wait for a lock

Mutex & operator<<(

const MutexAttributes & a
)


int set_attributes(

const MutexAttributes & attr
)

Sets the mutex attributes.


int try_lock()

Attempts to lock the mutex.

If the mutex is locked by another thread, the method returns immediately, returns less than zero, and sets errno to EBUSY.

If the mutex is locked by the current thread, it will be incremented if it is recursive or just return zero and keep the lock if non-recursive.


int unlock()

Unlocks the mutex.


X

Thanks for Coming!

Subscribe to news and updates