aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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