From 530014a3cce53e86dce8917e98a4e86d02f176aa Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 26 Apr 2007 15:06:49 +0000 Subject: 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. --- src/itocondition.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/itocondition.cpp (limited to 'src/itocondition.cpp') 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 @@ +#include + +#include "itocondition.h" + +Bu::ItoCondition::ItoCondition() +{ + pthread_cond_init( &cond, NULL ); +} + +Bu::ItoCondition::~ItoCondition() +{ + pthread_cond_destroy( &cond ); +} + +int Bu::ItoCondition::wait() +{ + return pthread_cond_wait( &cond, &mutex ); +} + +int Bu::ItoCondition::wait( int nSec, int nUSec ) +{ + struct timeval now; + struct timespec timeout; + struct timezone tz; + + gettimeofday( &now, &tz ); + timeout.tv_sec = now.tv_sec + nSec + ((now.tv_usec + nUSec)/1000000); + timeout.tv_nsec = ((now.tv_usec + nUSec)%1000000)*1000; + + return pthread_cond_timedwait( &cond, &mutex, &timeout ); +} + +int Bu::ItoCondition::signal() +{ + return pthread_cond_signal( &cond ); +} + +int Bu::ItoCondition::broadcast() +{ + return pthread_cond_broadcast( &cond ); +} + -- cgit v1.2.3