mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-17 11:05:03 +02:00
trunk: backport eventing from 1.4.3
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ScopedLock.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/ScopedLock.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/ScopedLock.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -48,27 +48,27 @@ namespace Poco {
|
||||
|
||||
template <class M>
|
||||
class ScopedLock
|
||||
/// A class that simplifies thread synchronization
|
||||
/// with a mutex.
|
||||
/// The constructor accepts a Mutex (and optionally
|
||||
/// a timeout value in milliseconds) and locks it.
|
||||
/// The destructor unlocks the mutex.
|
||||
/// A class that simplifies thread synchronization
|
||||
/// with a mutex.
|
||||
/// The constructor accepts a Mutex (and optionally
|
||||
/// a timeout value in milliseconds) and locks it.
|
||||
/// The destructor unlocks the mutex.
|
||||
{
|
||||
public:
|
||||
explicit ScopedLock(M& mutex): _mutex(mutex)
|
||||
{
|
||||
_mutex.lock();
|
||||
}
|
||||
|
||||
ScopedLock(M& mutex, long milliseconds): _mutex(mutex)
|
||||
{
|
||||
_mutex.lock(milliseconds);
|
||||
}
|
||||
|
||||
~ScopedLock()
|
||||
{
|
||||
_mutex.unlock();
|
||||
}
|
||||
explicit ScopedLock(M& mutex): _mutex(mutex)
|
||||
{
|
||||
_mutex.lock();
|
||||
}
|
||||
|
||||
ScopedLock(M& mutex, long milliseconds): _mutex(mutex)
|
||||
{
|
||||
_mutex.lock(milliseconds);
|
||||
}
|
||||
|
||||
~ScopedLock()
|
||||
{
|
||||
_mutex.unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
M& _mutex;
|
||||
@@ -81,28 +81,28 @@ private:
|
||||
|
||||
template <class M>
|
||||
class ScopedLockWithUnlock
|
||||
/// A class that simplifies thread synchronization
|
||||
/// with a mutex.
|
||||
/// The constructor accepts a Mutex (and optionally
|
||||
/// a timeout value in milliseconds) and locks it.
|
||||
/// The destructor unlocks the mutex.
|
||||
/// The unlock() member function allows for manual
|
||||
/// unlocking of the mutex.
|
||||
/// A class that simplifies thread synchronization
|
||||
/// with a mutex.
|
||||
/// The constructor accepts a Mutex (and optionally
|
||||
/// a timeout value in milliseconds) and locks it.
|
||||
/// The destructor unlocks the mutex.
|
||||
/// The unlock() member function allows for manual
|
||||
/// unlocking of the mutex.
|
||||
{
|
||||
public:
|
||||
explicit ScopedLockWithUnlock(M& mutex): _pMutex(&mutex)
|
||||
{
|
||||
_pMutex->lock();
|
||||
}
|
||||
|
||||
ScopedLockWithUnlock(M& mutex, long milliseconds): _pMutex(&mutex)
|
||||
{
|
||||
_pMutex->lock(milliseconds);
|
||||
}
|
||||
|
||||
~ScopedLockWithUnlock()
|
||||
{
|
||||
unlock();
|
||||
explicit ScopedLockWithUnlock(M& mutex): _pMutex(&mutex)
|
||||
{
|
||||
_pMutex->lock();
|
||||
}
|
||||
|
||||
ScopedLockWithUnlock(M& mutex, long milliseconds): _pMutex(&mutex)
|
||||
{
|
||||
_pMutex->lock(milliseconds);
|
||||
}
|
||||
|
||||
~ScopedLockWithUnlock()
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
|
||||
void unlock()
|
||||
|
Reference in New Issue
Block a user