atscppapi  1.0.9
C++ wrapper for Apache Traffic Server API
 All Classes Files Functions Enumerations Enumerator Macros
Public Types | Public Member Functions | List of all members
atscppapi::Mutex Class Reference

A mutex is mutual exclusion: a blocking lock. More...

#include "Mutex.h"

Inherits atscppapi::noncopyable.

Public Types

enum  Type { TYPE_NORMAL = 0, TYPE_RECURSIVE, TYPE_ERROR_CHECK }
 

Public Member Functions

 Mutex (Type type=TYPE_NORMAL)
 
bool tryLock ()
 
void lock ()
 
void unlock ()
 

Detailed Description

A mutex is mutual exclusion: a blocking lock.

The Mutex class uses pthreads for its implmentation.

See Also
ScopedMutexLock
ScopedMutexTryLock
ScopedSharedMutexLock
ScopedSharedMutexTryLock

Member Enumeration Documentation

The available types of Mutexes.

Enumerator
TYPE_NORMAL 

This type of Mutex will deadlock if locked by a thread already holding the lock

TYPE_RECURSIVE 

This type of Mutex will allow a thread holding the lock to lock it again; however, it must be unlocked the same number of times

TYPE_ERROR_CHECK 

This type of Mutex will return errno = EDEADLCK if a thread would deadlock by taking the lock after it already holds it

Constructor & Destructor Documentation

atscppapi::Mutex::Mutex ( Type  type = TYPE_NORMAL)
inline

Create a mutex

Parameters
typeThe Type of Mutex to create, the default is TYPE_NORMAL.
See Also
Type

Member Function Documentation

void atscppapi::Mutex::lock ( )
inline

Block until the lock is taken, when this call returns the thread will be holding the lock.

bool atscppapi::Mutex::tryLock ( )
inline

Try to take the lock, this call will NOT block if the mutex cannot be taken.

Returns
Returns true if the lock was taken, false if it was not. This call obviously will not block.
void atscppapi::Mutex::unlock ( )
inline

Unlock the lock, this call is nonblocking.


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