RTP Audio System  2.0.0
Synchronizable Class Reference

Synchronizable. More...

#include <synchronizable.h>

Inheritance diagram for Synchronizable:
Condition MultiAudioWriter SimpleAudioDecoder SourceStateInfo SpectrumAnalyzer Thread TrafficShaper MessageQueue< T > RingBuffer AudioDevice MediaServent MultiTimerThread< Timers > RTCPReceiver RTPReceiver TestReceiver VerificationClientThread

List of all members.

Public Member Functions

 Synchronizable (const char *name="Synchronizable", const bool recursive=true)
 ~Synchronizable ()
void synchronized ()
bool synchronizedTry ()
void unsynchronized ()
void resynchronize ()
const char * getName () const
void setName (const char *name)

Static Public Member Functions

static bool setCancelState (const bool enabled)

Protected Attributes

pthread_mutex_t Mutex
bool Recursive
char MutexName [64]

Detailed Description

Synchronizable.

This class realizes synchronized access to a thread's data by other threads. Synchronization is done by using a global pthread mutex and obtaining access to this mutex by synchronized() for synchronized access and releasing this mutex for unsynchronized access. IMPORTANT: Do *not* use synchronized()/unsynchronized() within async signal handlers. This may cause deadlocks. See PThread's pthread_mutex_lock man-page, section "Async Signal Safety" for more information!

Author:
Thomas Dreibholz
Version:
1.0
See also:
Thread

Constructor & Destructor Documentation

Synchronizable::Synchronizable ( const char *  name = "Synchronizable",
const bool  recursive = true 
)

Constructor.

Parameters:
nameName.
recursivetrue to make mutex recursive (default); false otherwise.

Member Function Documentation

const char* Synchronizable::getName ( ) const [inline]

Get name of synchronizable object.

Returns:
Name.

Do reinitialization of Synchronizable.

static bool Synchronizable::setCancelState ( const bool  enabled) [inline, static]

Enable or disable cancelability of calling thread.

Parameters:
enabledtrue to enable cancellation; false otherwise.
void Synchronizable::setName ( const char *  name) [inline]

Set name of synchronizable object.

Parameters:
nameName.
void Synchronizable::synchronized ( ) [inline]

synchronized() begins a synchronized block. The block has to be finished by unsynchronized(). synchronized() will wait until the mutex is available.

See also:
unsynchronized
synchronizedTry

synchronizedTry() tries to begins a synchronized block. It does the same as synchronized(), but returns immediately, if the mutex is obtained by another thread.

See also:
synchronized
unsynchronized
void Synchronizable::unsynchronized ( ) [inline]

unsynchronized() ends a synchronized block, which has begun by synchronized().

See also:
synchronized

Member Data Documentation

pthread_mutex_t Synchronizable::Mutex [protected]
char Synchronizable::MutexName[64] [protected]
bool Synchronizable::Recursive [protected]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines