diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2003-10-17 15:36:42 +0000 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2003-10-17 15:36:42 +0000 |
| commit | d63d2c3c6cbbd574dda4f8b00ebe6c661735edd5 (patch) | |
| tree | 84d0cacfd0b6c1241c236c7860f7cbd7f26901bb /lib/base/elock.h | |
| download | enigma2-d63d2c3c6cbbd574dda4f8b00ebe6c661735edd5.tar.gz enigma2-d63d2c3c6cbbd574dda4f8b00ebe6c661735edd5.zip | |
import of enigma2
Diffstat (limited to 'lib/base/elock.h')
| -rw-r--r-- | lib/base/elock.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/base/elock.h b/lib/base/elock.h new file mode 100644 index 00000000..6a47f8c9 --- /dev/null +++ b/lib/base/elock.h @@ -0,0 +1,60 @@ +#ifndef __elock_h +#define __elock_h + +#include <pthread.h> + +class singleLock +{ + pthread_mutex_t &lock; +public: + singleLock( pthread_mutex_t &m ) + :lock(m) + { + pthread_mutex_lock(&lock); + } + ~singleLock() + { + pthread_mutex_unlock(&lock); + } +}; + +class eLock +{ + pthread_mutex_t mutex; + pthread_cond_t cond; + + int pid; + int counter, max; +public: + void lock(int res=100); + void unlock(int res=100); + + eLock(int max=100); + ~eLock(); +}; + +class eLocker +{ + eLock &lock; + int res; +public: + eLocker(eLock &lock, int res=100); + ~eLocker(); +}; + +class eSemaphore +{ + int v; + pthread_mutex_t mutex; + pthread_cond_t cond; +public: + eSemaphore(); + ~eSemaphore(); + + int down(); + int decrement(); + int up(); + int value(); +}; + +#endif |
