Update of /cvsroot/pclasses/pclasses2/src/System
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17607/src/System
Modified Files:
Mutex.cpp CriticalSection.cpp
Log Message:
Added copy-ctor and assignment operator to Mutex::ScopedLock and
CriticalSection::ScopedLock.
Index: CriticalSection.cpp
===================================================================
RCS file: /cvsroot/pclasses/pclasses2/src/System/CriticalSection.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- CriticalSection.cpp 22 Dec 2004 17:54:36 -0000 1.1.1.1
+++ CriticalSection.cpp 23 Jan 2005 13:28:00 -0000 1.2
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2004 by Christian Prochnow *
+ * Copyright (C) 2004,2005 by Christian Prochnow *
* cp...@se... *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -30,6 +30,13 @@
cs.lock();
}
+CriticalSection::ScopedLock::ScopedLock(const ScopedLock& lck) throw()
+: _cs(lck._cs)
+{
+ if(_cs)
+ _cs->lock();
+}
+
CriticalSection::ScopedLock::~ScopedLock() throw()
{
release();
@@ -53,6 +60,16 @@
return *this;
}
+CriticalSection::ScopedLock&
+ CriticalSection::ScopedLock::operator=(const ScopedLock& lck) throw()
+{
+ release();
+ _cs = lck._cs;
+ if(_cs)
+ _cs->lock();
+ return *this;
+}
+
} // !namespace System
} // !namespace P
Index: Mutex.cpp
===================================================================
RCS file: /cvsroot/pclasses/pclasses2/src/System/Mutex.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Mutex.cpp 22 Dec 2004 17:54:35 -0000 1.1.1.1
+++ Mutex.cpp 23 Jan 2005 13:28:00 -0000 1.2
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2004 by Christian Prochnow *
+ * Copyright (C) 2004,2005 by Christian Prochnow *
* cp...@se... *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -30,6 +30,13 @@
mutex.lock();
}
+Mutex::ScopedLock::ScopedLock(const ScopedLock& lck) throw(SystemError)
+: _mutex(lck._mutex)
+{
+ if(_mutex)
+ _mutex->lock();
+}
+
Mutex::ScopedLock::~ScopedLock() throw()
{
try { release(); }
@@ -54,6 +61,17 @@
return *this;
}
+Mutex::ScopedLock& Mutex::ScopedLock::operator=(const ScopedLock& lck)
+ throw(SystemError)
+{
+ release();
+ _mutex = lck._mutex;
+ if(_mutex)
+ _mutex->lock();
+ return *this;
+}
+
+
} // !namespace System
} // !namespace P
|