mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 19:10:20 +01:00
Merge branch 'issue_532' into issue_532-3 with edits
This commit is contained in:
@@ -45,16 +45,13 @@ class Foundation_API Mutex: private MutexImpl
|
||||
/// A Mutex (mutual exclusion) is a synchronization
|
||||
/// mechanism used to control access to a shared resource
|
||||
/// in a concurrent (multithreaded) scenario.
|
||||
/// Mutexes are recursive, that is, the same mutex can be
|
||||
/// locked multiple times by the same thread (but, of course,
|
||||
/// not by other threads).
|
||||
/// Using the ScopedLock class is the preferred way to automatically
|
||||
/// lock and unlock a mutex.
|
||||
{
|
||||
public:
|
||||
typedef Poco::ScopedLock<Mutex> ScopedLock;
|
||||
|
||||
Mutex();
|
||||
explicit Mutex(bool recursive = true);
|
||||
/// creates the Mutex.
|
||||
|
||||
~Mutex();
|
||||
|
||||
@@ -32,8 +32,7 @@ namespace Poco {
|
||||
class Foundation_API MutexImpl
|
||||
{
|
||||
protected:
|
||||
MutexImpl();
|
||||
MutexImpl(bool fast);
|
||||
MutexImpl(bool recursive);
|
||||
~MutexImpl();
|
||||
void lockImpl();
|
||||
bool tryLockImpl();
|
||||
|
||||
@@ -32,8 +32,7 @@ namespace Poco {
|
||||
class Foundation_API MutexImpl
|
||||
{
|
||||
protected:
|
||||
MutexImpl();
|
||||
MutexImpl(bool fast);
|
||||
MutexImpl(bool recursive);
|
||||
~MutexImpl();
|
||||
void lockImpl();
|
||||
bool tryLockImpl();
|
||||
|
||||
@@ -31,25 +31,46 @@ namespace Poco {
|
||||
class Foundation_API MutexImpl
|
||||
{
|
||||
protected:
|
||||
MutexImpl();
|
||||
MutexImpl(bool recursive);
|
||||
~MutexImpl();
|
||||
void lockImpl();
|
||||
bool tryLockImpl();
|
||||
bool tryLockImpl(long milliseconds);
|
||||
void unlockImpl();
|
||||
|
||||
private:
|
||||
CRITICAL_SECTION _cs;
|
||||
int _lockCount;
|
||||
const bool _recursive;
|
||||
};
|
||||
|
||||
|
||||
class Foundation_API FastMutexImpl
|
||||
{
|
||||
protected:
|
||||
FastMutexImpl();
|
||||
~FastMutexImpl();
|
||||
void lockImpl();
|
||||
bool tryLockImpl();
|
||||
bool tryLockImpl(long milliseconds);
|
||||
void unlockImpl();
|
||||
|
||||
private:
|
||||
CRITICAL_SECTION _cs;
|
||||
};
|
||||
|
||||
|
||||
typedef MutexImpl FastMutexImpl;
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline void MutexImpl::lockImpl()
|
||||
inline void MutexImpl::unlockImpl()
|
||||
{
|
||||
--_lockCount;
|
||||
LeaveCriticalSection(&_cs);
|
||||
}
|
||||
|
||||
|
||||
inline void FastMutexImpl::lockImpl()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -62,7 +83,7 @@ inline void MutexImpl::lockImpl()
|
||||
}
|
||||
|
||||
|
||||
inline bool MutexImpl::tryLockImpl()
|
||||
inline bool FastMutexImpl::tryLockImpl()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -75,7 +96,7 @@ inline bool MutexImpl::tryLockImpl()
|
||||
}
|
||||
|
||||
|
||||
inline void MutexImpl::unlockImpl()
|
||||
inline void FastMutexImpl::unlockImpl()
|
||||
{
|
||||
LeaveCriticalSection(&_cs);
|
||||
}
|
||||
|
||||
@@ -31,21 +31,35 @@ namespace Poco {
|
||||
class Foundation_API MutexImpl
|
||||
{
|
||||
protected:
|
||||
MutexImpl();
|
||||
MutexImpl(bool recursive);
|
||||
~MutexImpl();
|
||||
void lockImpl();
|
||||
bool tryLockImpl();
|
||||
bool tryLockImpl(long milliseconds);
|
||||
void unlockImpl();
|
||||
|
||||
private:
|
||||
HANDLE _mutex;
|
||||
int _lockCount;
|
||||
const bool _recursive;
|
||||
};
|
||||
|
||||
|
||||
class Foundation_API FastMutexImpl
|
||||
{
|
||||
protected:
|
||||
FastMutexImpl();
|
||||
~FastMutexImpl();
|
||||
void lockImpl();
|
||||
bool tryLockImpl();
|
||||
bool tryLockImpl(long milliseconds);
|
||||
void unlockImpl();
|
||||
|
||||
private:
|
||||
HANDLE _mutex;
|
||||
};
|
||||
|
||||
|
||||
typedef MutexImpl FastMutexImpl;
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user