RTP Trace System  1.0
Coral::Synchronizable Class Reference

Synchronizable. More...

#include <synchronizable.h>

Inheritance diagram for Coral::Synchronizable:
Coral::SourceStateInfo Coral::Thread Coral::TraceDecoder Coral::TrafficShaper Coral::RTCPReceiver Coral::RTPReceiver Coral::TimedThread VerificationClientThread Coral::BandwidthManager Coral::RoundTripTimePinger Coral::RTCPAbstractServer Coral::RTCPSender Coral::RTPSender Coral::TrafficShaperSingleton SenderThread Coral::TraceServer

List of all members.

Public Member Functions

 Synchronizable ()
 ~Synchronizable ()
void synchronized ()
bool synchronizedTry ()
void unsynchronized ()
void resynchronize ()
void synchronized_debug (const char *file, const cardinal line)
void unsynchronized_debug (const char *file, const cardinal line)
bool synchronizedTry_debug (const char *file, const cardinal line)
void resynchronize_debug (const char *file, const cardinal line)

Private Attributes

pthread_mutex_t Mutex

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


Member Function Documentation

Do reinitialization of Synchronizable.

void Coral::Synchronizable::resynchronize_debug ( const char *  file,
const cardinal  line 
)

Debug version of resynchronize. This will print PID, file name and line number, followed by debug information.

Parameters:
fileFile name.
lineLine number.
See also:
resynchronize

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
void Coral::Synchronizable::synchronized_debug ( const char *  file,
const cardinal  line 
)

Debug version of synchronized. This will print PID, file name and line number, followed by debug information.

Parameters:
fileFile name.
lineLine number.
See also:
synchronized

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
bool Coral::Synchronizable::synchronizedTry_debug ( const char *  file,
const cardinal  line 
)

Debug version of synchronizedTry. This will print PID, file name and line number, followed by debug information.

Parameters:
fileFile name.
lineLine number.
See also:
synchronizedTry

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

See also:
synchronized
void Coral::Synchronizable::unsynchronized_debug ( const char *  file,
const cardinal  line 
)

Debug version of unsynchronized. This will print PID, file name and line number, followed by debug information.

Parameters:
fileFile name.
lineLine number.
See also:
unsynchronized

Member Data Documentation

pthread_mutex_t Coral::Synchronizable::Mutex [private]

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