Changeset 1131:43a91b33f374 in lemon for lemon/bits
- Timestamp:
- 01/29/12 11:28:41 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- lemon/bits
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/bits/alteration_notifier.h
r463 r1131 24 24 25 25 #include <lemon/core.h> 26 #include <lemon/bits/lock.h> 26 27 27 28 //\ingroup graphbits … … 252 253 typedef std::list<ObserverBase*> Observers; 253 254 Observers _observers; 254 255 lemon::bits::Lock _lock; 255 256 256 257 public: … … 333 334 334 335 void attach(ObserverBase& observer) { 336 _lock.lock(); 335 337 observer._index = _observers.insert(_observers.begin(), &observer); 336 338 observer._notifier = this; 339 _lock.unlock(); 337 340 } 338 341 339 342 void detach(ObserverBase& observer) { 343 _lock.lock(); 340 344 _observers.erase(observer._index); 341 345 observer._index = _observers.end(); 342 346 observer._notifier = 0; 347 _lock.unlock(); 343 348 } 344 349 -
lemon/bits/windows.cc
r1055 r1131 131 131 #endif 132 132 } 133 134 WinLock::WinLock() { 135 #ifdef WIN32 136 CRITICAL_SECTION *lock = new CRITICAL_SECTION; 137 InitializeCriticalSection(lock); 138 _repr = lock; 139 #endif 140 } 141 142 WinLock::~WinLock() { 143 #ifdef WIN32 144 CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr); 145 DeleteCriticalSection(lock); 146 delete lock; 147 #endif 148 } 149 150 void WinLock::lock() { 151 #ifdef WIN32 152 CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr); 153 EnterCriticalSection(lock); 154 #endif 155 } 156 157 void WinLock::unlock() { 158 #ifdef WIN32 159 CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr); 160 LeaveCriticalSection(lock); 161 #endif 162 } 133 163 } 134 164 } -
lemon/bits/windows.h
r576 r1131 29 29 std::string getWinFormattedDate(); 30 30 int getWinRndSeed(); 31 32 class WinLock { 33 public: 34 WinLock(); 35 ~WinLock(); 36 void lock(); 37 void unlock(); 38 private: 39 void *_repr; 40 }; 31 41 } 32 42 }
Note: See TracChangeset
for help on using the changeset viewer.