TSDuck Version 3.15-955 (TSDuck - The MPEG Transport Stream Toolkit)
ts::MutexInterface Class Referenceabstract

Interface class for mutex objects. More...

Inheritance diagram for ts::MutexInterface:

Public Member Functions

virtual ~MutexInterface ()
 Virtual destructor.
virtual bool acquire (MilliSecond timeout=Infinite)=0
 Acquire the mutex with a timeout. More...
virtual bool release ()=0
 Release the mutex. More...

Detailed Description

Interface class for mutex objects.

A mutex is a general mutual exclusion mechanism. This interface class defines the generic interface of a mutex. Various concrete mutex classes can be defined based on distinct lower-level synchronization mechanisms.

For each successful call to acquire(), there must be one call to release().

This interface class does not define whether the actual mutex should be recursive or not. A mutex is defined as recursive if nested pairs of acquire() / release() are allowed on the mutex. If the implementation is a recursive mutex, there must be exactly one release() for each nested invocation of acquire().

The concrete class ts::NullMutex is an empty mutex implementation which does nothing and can be used wherever a MutexInterface is required but no actual synchronization is necessary (non-threaded applications for instances).

Member Function Documentation

◆ acquire()

virtual bool ts::MutexInterface::acquire ( MilliSecond  timeout = Infinite)
pure virtual

Acquire the mutex with a timeout.

The actual semantic of this operation depends on the mutex concrete class. Typically, the concrete class attempts to acquire a low-level synchronization mechanism and blocks until the mutex is granted or a timeout occurs.

[in]timeoutMaximum number of milliseconds to wait for the mutex.
True on success and false on error or timeout. When false is returned, it is not possible to determine whether this was an error or a timeout.

Implemented in ts::Mutex, and ts::NullMutex.

◆ release()

virtual bool ts::MutexInterface::release ( )
pure virtual

Release the mutex.

true on success and false on error.

Implemented in ts::Mutex, and ts::NullMutex.

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