Changeset 4872 for branches/erijo-dev
- Timestamp:
- 03/20/07 05:21:24 (21 months ago)
- Location:
- branches/erijo-dev/licq/src/utils
- Files:
-
- 3 modified
-
mutexlocker.cpp (modified) (1 diff)
-
mutexlocker.h (modified) (2 diffs)
-
tests/mutexlockertest.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/erijo-dev/licq/src/utils/mutexlocker.cpp
r4847 r4872 22 22 #include <cassert> 23 23 24 Licq::TMutexLocker::TMutexLocker(TMutex* mutex )24 Licq::TMutexLocker::TMutexLocker(TMutex* mutex, TCreateOption option) 25 25 : Mutex(mutex), Locked(false) 26 26 { 27 // Empty 27 if (option == CREATE_LOCKED) 28 lock(); 28 29 } 29 30 -
branches/erijo-dev/licq/src/utils/mutexlocker.h
r4839 r4872 48 48 { 49 49 TMutexLocker locker(&Mutex); 50 locker.lock();51 50 return Counter++; 52 51 } … … 61 60 62 61 public: 62 enum TCreateOption { CREATE_LOCKED, CREATE_UNLOCKED }; 63 63 /** \brief Create a new TMutexLocker. 64 64 65 Does \b not lock \a mutex.66 67 65 \param[in] mutex Must be a mutex \b not locked by this thread. 66 \param[in] option Lock the mutex if option is CREATE_LOCKED. 68 67 */ 69 TMutexLocker(TMutex* mutex );68 TMutexLocker(TMutex* mutex, TCreateOption option = CREATE_LOCKED); 70 69 71 70 /// Unlock the mutex if it was previous locked in lock() or tryLock(). -
branches/erijo-dev/licq/src/utils/tests/mutexlockertest.cpp
r4847 r4872 33 33 { 34 34 TMutexLocker locker(&mutex); 35 BOOST_CHECK_EQUAL(mutex.isLocked(), true); 36 } 37 38 BOOST_CHECK_EQUAL(mutex.isLocked(), false); 39 40 { 41 TMutexLocker locker(&mutex, TMutexLocker::CREATE_UNLOCKED); 35 42 BOOST_CHECK_EQUAL(mutex.isLocked(), false); 36 43 … … 49 56 // This test requires that TMutex is built with DEBUG (and __USE_GNU) defined. 50 57 { 51 TMutexLocker locker(&mutex );58 TMutexLocker locker(&mutex, TMutexLocker::CREATE_UNLOCKED); 52 59 locker.lock(); 53 60
