Rudiments: threadmutex Class Reference

Rudiments

- Main Page
- Classes

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
threadmutex Class Reference

## Public Member Functions
| threadmutex ()
| threadmutex (void *mut)
| ~threadmutex ()
bool | lock ()
bool | tryLock ()
bool | unlock ()
void * | getInternalMutexStructure ()

## Detailed Description

The threadmutex class provides mutual exclusion locks between separate threads of a single process.

## Constructor & Destructor Documentation

threadmutex::threadmutex | ( |  | ) |

Creates an instance of the threadmutex class.

threadmutex::threadmutex | ( | void * | mut | ) |

Creates an instance of the threadmutex class that uses an already-initialized, system-specific threadmutex structure. On unix systems, this would likely be an instance of struct pthread_mutex_t, though it could possibly be something else.

threadmutex::~threadmutex | ( |  | ) |

Deletes this instance of the threadmutex class.

## Member Function Documentation

void* threadmutex::getInternalMutexStructure | ( |  | ) |

Returns the mutex structure used by the class internally. On unix systems this would most likely be a struct pthread_mutex_t *, though it could possibly be something else.

bool threadmutex::lock | ( |  | ) |

Locks the mutex. Will wait until the lock succeds. Returns true on success and false if an error occurs.

bool threadmutex::tryLock | ( |  | ) |

Attempts to lock the mutex. Will return immediately if the mutex could not be locked, returning false and setting errno to EBUSY. Returns true on success and false if an error occurs.

bool threadmutex::unlock | ( |  | ) |

Unlocks the mutex. Returns true on success and false if an error occurs.