kodi
Public Member Functions | Protected Attributes | Friends | List of all members
XbmcThreads::CountingLockable< L > Class Template Reference

This template will take any implementation of the "Lockable" concept and allow it to be used as an "Exitable Lockable.". More...

#include <Lockables.h>

Public Member Functions

void lock ()
 
bool try_lock ()
 
void unlock ()
 
bool IsLocked () const
 Check if have a lock owned. More...
 
unsigned int exit (unsigned int leave=0)
 This implements the "exitable" behavior mentioned above.
 
void restore (unsigned int restoreCount)
 Restore a previous exit to the provided level.
 
L & get_underlying ()
 Some implementations (see pthreads) require access to the underlying CCriticalSection, which is also implementation specific. More...
 

Protected Attributes

mutex
 
unsigned int count = 0
 

Friends

class ConditionVariable
 

Detailed Description

template<class L>
class XbmcThreads::CountingLockable< L >

This template will take any implementation of the "Lockable" concept and allow it to be used as an "Exitable Lockable.".

Something that implements the "Lockable concept" simply means that it has the three methods:

lock(); try_lock(); unlock(); IsLocked();

"Exitable" specifically means that, no matter how deep the recursion on the mutex/critical section, we can exit from it and then restore the state.

This requires us to extend the Lockable so that we can keep track of the number of locks that have been recursively acquired so that we can undo it, and then restore that (See class CSingleExit).

All xbmc code expects Lockables to be recursive.

Member Function Documentation

◆ get_underlying()

template<class L >
L& XbmcThreads::CountingLockable< L >::get_underlying ( )
inline

Some implementations (see pthreads) require access to the underlying CCriticalSection, which is also implementation specific.

This provides access to it through the same method on the guard classes UniqueLock, and SharedLock.

There really should be no need for the users of the threading library to call this method.

◆ IsLocked()

template<class L >
bool XbmcThreads::CountingLockable< L >::IsLocked ( ) const
inline

Check if have a lock owned.

Returns
True if have a lock, otherwise false

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