aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source/flsupport.h
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2003-01-30 04:36:06 +0000
committerThomas Grill <xovo@users.sourceforge.net>2003-01-30 04:36:06 +0000
commit392f24a84a7ca535a7132cfe0a8da55aa28733ce (patch)
tree9b546e31a6d682c1abf67afb4c06397c488683a2 /externals/grill/flext/source/flsupport.h
parentc1313aea8746276cc4de4dbd177f6bf732db2a05 (diff)
""
svn path=/trunk/; revision=366
Diffstat (limited to 'externals/grill/flext/source/flsupport.h')
-rw-r--r--externals/grill/flext/source/flsupport.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h
index 3f771ea0..e2350d04 100644
--- a/externals/grill/flext/source/flsupport.h
+++ b/externals/grill/flext/source/flsupport.h
@@ -16,6 +16,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define __FLSUPPORT_H
#include "flstdc.h"
+#include <time.h>
class FLEXT_SHARE flext_base;
@@ -729,11 +730,24 @@ public:
}
/*! \brief Wait for condition (for a certain time)
- \param time Wait time in seconds
+ \param ftime Wait time in seconds
+ \ret 0 = signalled, 1 = timed out
+ \remark Depending on the implementation ftime may not be fractional.
+ \remark So if ftime = 0 this may suck away your cpu if used in a signalled loop.
*/
- bool TimedWait(float time)
+ bool TimedWait(float ftime)
{
- timespec tm; tm.tv_sec = (long)time; tm.tv_nsec = (long)((time-(long)time)*1.e9);
+ timespec tm;
+#if 0 // find out when the following is defined
+ clock_gettime(CLOCK_REALTIME,tm);
+ tm.tv_nsec += (long)((ftime-(long)ftime)*1.e9);
+ long nns = tm.tv_nsec%1000000000;
+ tm.tv_sec += (long)ftime+(tm.tv_nsec-nns)/1000000000;
+ tm.tv_nsec = nns;
+#else
+ tm.tv_sec = time(NULL)+(long)ftime;
+ tm.tv_nsec = 0;
+#endif
Lock();
bool ret = pthread_cond_timedwait(&cond,&mutex,&tm) == 0;
Unlock();