diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-07-03 00:28:59 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-07-03 00:28:59 +0000 |
commit | ac517a2b7625e0aa0862679e961c6349f859ea3b (patch) | |
tree | e3e27a6b9bd5e2be6150088495c91fc91786ad9d /src/itocondition.cpp | |
parent | f8d4301e9fa4f3709258505941e37fab2eadadc6 (diff) | |
parent | bd865cee5f89116c1f054cd0e5c275e97c2d0a9b (diff) | |
download | libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.gz libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.bz2 libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.xz libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.zip |
The reorg is being put in trunk, I think it's ready. Now we just get to find
out how many applications won't work anymore :)
Diffstat (limited to '')
-rw-r--r-- | src/itocondition.cpp | 42 |
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 | |||
5 | Bu::ItoCondition::ItoCondition() | ||
6 | { | ||
7 | pthread_cond_init( &cond, NULL ); | ||
8 | } | ||
9 | |||
10 | Bu::ItoCondition::~ItoCondition() | ||
11 | { | ||
12 | pthread_cond_destroy( &cond ); | ||
13 | } | ||
14 | |||
15 | int Bu::ItoCondition::wait() | ||
16 | { | ||
17 | return pthread_cond_wait( &cond, &mutex ); | ||
18 | } | ||
19 | |||
20 | int 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 | |||
33 | int Bu::ItoCondition::signal() | ||
34 | { | ||
35 | return pthread_cond_signal( &cond ); | ||
36 | } | ||
37 | |||
38 | int Bu::ItoCondition::broadcast() | ||
39 | { | ||
40 | return pthread_cond_broadcast( &cond ); | ||
41 | } | ||
42 | |||