aboutsummaryrefslogtreecommitdiff
path: root/src/itocondition.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-04-26 15:06:49 +0000
committerMike Buland <eichlan@xagasoft.com>2007-04-26 15:06:49 +0000
commit530014a3cce53e86dce8917e98a4e86d02f176aa (patch)
treec667c996fb91692b101f75296206b8420f19bf73 /src/itocondition.cpp
parent066282ae6de25cf92780dbdaa2fd70a033e95659 (diff)
downloadlibbu++-530014a3cce53e86dce8917e98a4e86d02f176aa.tar.gz
libbu++-530014a3cce53e86dce8917e98a4e86d02f176aa.tar.bz2
libbu++-530014a3cce53e86dce8917e98a4e86d02f176aa.tar.xz
libbu++-530014a3cce53e86dce8917e98a4e86d02f176aa.zip
Merged Ito and put it in the BU namespace. I should probably clean up the
formatting on the comments, some of the lines wrap, but I'm not too worried about it right now. I also fixed up the doxygen config and build.conf files so that everything is building nice and smooth now.
Diffstat (limited to 'src/itocondition.cpp')
-rw-r--r--src/itocondition.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/itocondition.cpp b/src/itocondition.cpp
new file mode 100644
index 0000000..d8f5375
--- /dev/null
+++ b/src/itocondition.cpp
@@ -0,0 +1,42 @@
1#include <sys/time.h>
2
3#include "itocondition.h"
4
5Bu::ItoCondition::ItoCondition()
6{
7 pthread_cond_init( &cond, NULL );
8}
9
10Bu::ItoCondition::~ItoCondition()
11{
12 pthread_cond_destroy( &cond );
13}
14
15int Bu::ItoCondition::wait()
16{
17 return pthread_cond_wait( &cond, &mutex );
18}
19
20int Bu::ItoCondition::wait( int nSec, int nUSec )
21{
22 struct timeval now;
23 struct timespec timeout;
24 struct timezone tz;
25
26 gettimeofday( &now, &tz );
27 timeout.tv_sec = now.tv_sec + nSec + ((now.tv_usec + nUSec)/1000000);
28 timeout.tv_nsec = ((now.tv_usec + nUSec)%1000000)*1000;
29
30 return pthread_cond_timedwait( &cond, &mutex, &timeout );
31}
32
33int Bu::ItoCondition::signal()
34{
35 return pthread_cond_signal( &cond );
36}
37
38int Bu::ItoCondition::broadcast()
39{
40 return pthread_cond_broadcast( &cond );
41}
42