diff options
author | David Robillard <d@drobilla.net> | 2007-12-04 23:02:14 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-12-04 23:02:14 +0000 |
commit | feab87ff3c9dce87ef127c8c7e42e6d51950aa2e (patch) | |
tree | 384de5815f2da11fb4079209fd186e6a361fad52 /raul/Semaphore.hpp | |
parent | 6bb9c35360b3919236ed1df997e2021f817f3d19 (diff) | |
download | raul-feab87ff3c9dce87ef127c8c7e42e6d51950aa2e.tar.gz raul-feab87ff3c9dce87ef127c8c7e42e6d51950aa2e.tar.bz2 raul-feab87ff3c9dce87ef127c8c7e42e6d51950aa2e.zip |
Added 'has_waiter' method for Semaphore.
Added new Command class, for e.g. coarse GUI->Engine RT safe events.
git-svn-id: http://svn.drobilla.net/lad/raul@947 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'raul/Semaphore.hpp')
-rw-r--r-- | raul/Semaphore.hpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/raul/Semaphore.hpp b/raul/Semaphore.hpp index 3bd6ac4..09f3f7a 100644 --- a/raul/Semaphore.hpp +++ b/raul/Semaphore.hpp @@ -42,8 +42,16 @@ public: inline ~Semaphore() { sem_destroy(&_sem); } - inline void reset(unsigned int initial) - { sem_destroy(&_sem); sem_init(&_sem, 0, initial); } + inline void reset(unsigned int initial) { + sem_destroy(&_sem); + sem_init(&_sem, 0, initial); + } + + inline bool has_waiter() { + int val; + sem_getvalue(&_sem, &val); + return (val <= 0); + } /** Increment (and signal any waiters). * |