Kodi Documentation  19.0
Kodi is an open source media player and entertainment hub.
XbmcThreads::CountingLockable< L > Class Template Reference

#include <Lockables.h>

Collaboration diagram for XbmcThreads::CountingLockable< L >:

Public Member Functions

 CountingLockable ()=default
 
void lock ()
 
bool try_lock ()
 
void unlock ()
 
unsigned int exit (unsigned int leave=0)
 
void restore (unsigned int restoreCount)
 
L & get_underlying ()
 

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();

"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.

Constructor & Destructor Documentation

◆ CountingLockable()

template<class L>
XbmcThreads::CountingLockable< L >::CountingLockable ( )
inlinedefault

Member Function Documentation

◆ exit()

template<class L>
unsigned int XbmcThreads::CountingLockable< L >::exit ( unsigned int  leave = 0)
inline

This implements the "exitable" behavior mentioned above.

◆ 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.

◆ lock()

template<class L>
void XbmcThreads::CountingLockable< L >::lock ( )
inline

◆ restore()

template<class L>
void XbmcThreads::CountingLockable< L >::restore ( unsigned int  restoreCount)
inline

Restore a previous exit to the provided level.

◆ try_lock()

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

◆ unlock()

template<class L>
void XbmcThreads::CountingLockable< L >::unlock ( )
inline

Friends And Related Function Documentation

◆ ConditionVariable

template<class L>
friend class ConditionVariable
friend

Member Data Documentation

◆ count

template<class L>
unsigned int XbmcThreads::CountingLockable< L >::count = 0
protected

◆ mutex

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

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