/** Release the OS-structures and free mutex data-structure. @see::osl_destroyMutex()
*/
~Mutex()
{
osl_destroyMutex(mutex);
}
/** Acquire the mutex, block if already acquired by another thread. @returnfalseifsystem-callfails. @see::osl_acquireMutex()
*/ bool acquire()
{ return osl_acquireMutex(mutex);
}
/** Try to acquire the mutex without blocking. @returnfalseifitcouldnotbeacquired. @see::osl_tryToAcquireMutex()
*/ bool tryToAcquire()
{ return osl_tryToAcquireMutex(mutex);
}
public: /** Acquires the object specified as parameter.
*/
Guard(T * pT_) : pT(pT_)
{
assert(pT != NULL);
pT->acquire();
}
/** Acquires the object specified as parameter.
*/
Guard(T & t) : pT(&t)
{
pT->acquire();
}
/** Releases the mutex or interface. */
~Guard()
{
pT->release();
}
};
/** Object lifetime scoped mutex object or interface lock with unlock. * *Usethisifyoucan'tusescopedcodeblocksandGuard. * *@seeClearableMutexGuard,Guard
*/ template<class T> class ClearableGuard
{
ClearableGuard( const ClearableGuard& ) SAL_DELETED_FUNCTION;
ClearableGuard& operator=(const ClearableGuard&) SAL_DELETED_FUNCTION;
protected:
T * pT;
public: /** Acquires the object specified as parameter.
*/
ClearableGuard(T * pT_) : pT(pT_)
{
assert(pT != NULL);
pT->acquire();
}
/** Acquires the object specified as parameter.
*/
ClearableGuard(T & t) : pT(&t)
{
pT->acquire();
}
/** Releases the mutex or interface if not already released by clear().
*/
~ClearableGuard()
{ if (pT)
pT->release();
}
/** Releases the mutex or interface.
*/ void clear()
{ #ifdef LIBO_INTERNAL_ONLY
assert(pT); #else if (pT) #endif
{
pT->release();
pT = NULL;
}
}
};
/** Template for temporary releasable mutex objects and interfaces locks. * *Usethisifyouwanttoacquirealockbutneedtotemporaryrelease *itandcan'tusemultiplescopedGuardobjects. * *@seeResettableMutexGuard
*/ template< class T > class ResettableGuard : public ClearableGuard< T >
{
ResettableGuard(const ResettableGuard&) SAL_DELETED_FUNCTION;
ResettableGuard& operator=(const ResettableGuard&) SAL_DELETED_FUNCTION;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.