cpp-pthread  (v1.7.3)
Simple C++ wrapper to pthread functions.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
Public Member Functions | Protected Attributes | Friends | List of all members
pthread::mutex Class Reference

#include <mutex.hpp>

Public Member Functions

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

Protected Attributes

pthread_mutex_t _mutex
 

Friends

class condition_variable
 

Detailed Description

The mutex class is a synchronization primitive that can be used to protect shared data from being simultaneously accessed by multiple threads.

Author
herbert koelman
Date
18/3/2016
Examples:
synchronized_queue_tests.cpp.

Definition at line 37 of file mutex.hpp.

Member Function Documentation

void pthread::mutex::lock ( )

The mutex object is locked (by calling pthread_mutex_lock). If the mutex is already locked, the calling thread blocks until the mutex becomes available. This operation returns with the mutex object referenced by mutex in the locked state with the calling thread as its owner.

Exceptions
mutex_exceptionif error conditions preventing this method to succeed.

Definition at line 24 of file mutex.cpp.

void pthread::mutex::try_lock ( )

The function pthread_mutex_trylock is identical to pthread_mutex_lock except tha if the mutex object referenced by mutex is currently locked (by any thread, including the current thread), the call returns immediately.

Exceptions
mutex_exceptionif error conditions preventing this method to succeed.
See also
lock

Definition at line 32 of file mutex.cpp.

void pthread::mutex::unlock ( )

The pthread_mutex_unlock function releases the mutex object referenced by mutex. The manner in which a mutex is released is dependent upon the mutex's type attribute. If there are threads blocked on the mutex object referenced by mutex when unlock is called, resulting in the mutex becoming available, the scheduling policy is used to determine which thread shall acquire the mutex.

Exceptions
mutex_exceptionif error conditions preventing this method to succeed.

Definition at line 40 of file mutex.cpp.

Member Data Documentation

pthread_mutex_t pthread::mutex::_mutex
protected

pthread mutex structure

Definition at line 74 of file mutex.hpp.


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