diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-04-16 13:33:53 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-04-16 13:33:53 +0200 |
commit | 4eb252df04ab237c8638d45bcbf028859dc6a110 (patch) | |
tree | 8bffddf62b4271336a6e0121fef8133327654000 /src/semaphore.h | |
parent | ef68248bf70a027595803b08433a7a2c74e20fd0 (diff) | |
parent | 35e804b984c28131fe13d229c5a0867762c6e8cf (diff) |
Merge branch 'settings'
Diffstat (limited to 'src/semaphore.h')
-rw-r--r-- | src/semaphore.h | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/semaphore.h b/src/semaphore.h index 4464898..d5995cb 100644 --- a/src/semaphore.h +++ b/src/semaphore.h @@ -24,22 +24,26 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __PRACRO_SEMAPHORE_H__ -#define __PRACRO_SEMAPHORE_H__ +#pragma once + +#include <chrono> struct semaphore_private_t; -class Semaphore { +class Semaphore +{ public: - Semaphore(const char *name = ""); - ~Semaphore(); + Semaphore(std::size_t initial_count = 0); + ~Semaphore(); + + void post(); - void post(); - void wait(); + //! Lock semaphore with timeout. + //! \returns true if the semaphore was locked, false on timeout. + bool wait(const std::chrono::milliseconds& timeout); + + void wait(); private: struct semaphore_private_t *prv{nullptr}; - const char *name{nullptr}; }; - -#endif/*__PRACRO_SEMAPHORE_H__*/ |