source:
orxonox.OLD/trunk/src/lib/util/threads/mutex_locker.h
@
10699
| Last change on this file since 10699 was 10618, checked in by bknecht, 19 years ago | |
|---|---|
| File size: 470 bytes | |
| Rev | Line | |
|---|---|---|
| [10574] | 1 | #ifndef __MUTEX_LOCKER_H__ |
| 2 | #define __MUTEX_LOCKER_H__ | |
| [10576] | 3 | |
| 4 | #include "mutex.h" | |
| 5 | ||
| 6 | namespace OrxThread | |
| [10574] | 7 | { |
| [10576] | 8 | |
| 9 | //! A Class that locks a Mutex within its scope | |
| [10577] | 10 | class MutexLocker |
| [10576] | 11 | { |
| [10574] | 12 | public: |
| 13 | //! Locks the Mutex mutex in this Scope. | |
| [10577] | 14 | MutexLocker(Mutex* mutex) { SDL_mutexP(mutex->getMutex()); this->mutex = mutex; }; |
| 15 | ~MutexLocker() { SDL_mutexV(mutex->getMutex()); }; | |
| [10574] | 16 | private: |
| 17 | Mutex* mutex; //!< The Mutex to lock. | |
| [10576] | 18 | }; |
| [10574] | 19 | } |
| 20 | ||
| 21 | #endif /* __MUTEX_LOCKER_H__ */ |
Note: See TracBrowser
for help on using the repository browser.










