aboutsummaryrefslogtreecommitdiff
path: root/src/stable
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2018-05-02 23:18:41 -0600
committerMike Buland <eichlan@xagasoft.com>2018-05-02 23:18:41 -0600
commitcaa56a972c203ff7938b3f972afc33080aac68c1 (patch)
tree99835f565375dfb54a9ed81113aa719c42c63bde /src/stable
parent446d6d2a80638c7bf5dfcb1aa3fc1eb3a2c729ec (diff)
downloadlibbu++-caa56a972c203ff7938b3f972afc33080aac68c1.tar.gz
libbu++-caa56a972c203ff7938b3f972afc33080aac68c1.tar.bz2
libbu++-caa56a972c203ff7938b3f972afc33080aac68c1.tar.xz
libbu++-caa56a972c203ff7938b3f972afc33080aac68c1.zip
Event added. It could be a little better.
Diffstat (limited to '')
-rw-r--r--src/stable/event.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/stable/event.h b/src/stable/event.h
new file mode 100644
index 0000000..d6c9f5e
--- /dev/null
+++ b/src/stable/event.h
@@ -0,0 +1,65 @@
1/*
2 * Copyright (C) 2007-2014 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#ifndef BU_EVENT_H
9#define BU_EVENT_H
10
11#include <pthread.h>
12
13#include "bu/mutex.h"
14#include "bu/condition.h"
15
16namespace Bu
17{
18 /**
19 *@ingroup Threading
20 */
21 class Event
22 {
23 public:
24 Event()
25 {
26 }
27
28 ~Event()
29 {
30 }
31
32 void wait()
33 {
34 cBlock.lock();
35 cBlock.wait();
36 cBlock.unlock();
37 }
38
39 void wait( int nSec, int nUSec )
40 {
41 cBlock.lock();
42 cBlock.wait( nSec, nUSec );
43 cBlock.unlock();
44 }
45
46 void unblockOne()
47 {
48 cBlock.lock();
49 cBlock.signal();
50 cBlock.unlock();
51 }
52
53 void unblockAll()
54 {
55 cBlock.lock();
56 cBlock.broadcast();
57 cBlock.unlock();
58 }
59
60 private:
61 Condition cBlock; /**< The condition for blocking dequeues. */
62 };
63}
64
65#endif