/*! ========================================================================
** Extended Template and Library
** Clock Abstraction Implementation
-** $Id: _clock_base.h,v 1.1.1.1 2005/01/04 01:31:46 darco Exp $
+** $Id$
**
** Copyright (c) 2002 Robert B. Quattlebaum Jr.
**
typedef typename DESC::timestamp timestamp;
timestamp base_time;
-
+
using DESC::get_current_time;
using DESC::realtime;
using DESC::one_second;
void reset()
{ get_current_time(base_time); }
-
+
value_type operator()()const
{ return timestamp_to_seconds(get_current_time()-base_time); }
{
// Grab the old base time
timestamp old_time=base_time;
-
+
// Put the current time into base_time
get_current_time(base_time);
-
+
return timestamp_to_seconds(base_time-old_time);
}
-
+
static void
sleep(const value_type &length)
{
value_type val;
for(val=timer();one_second()<length-val;val=timer())
::sleep((int)((length-val)/2.0+0.4));
- while(timer()<length);
+ while(timer()<length)
+ ;
}
/* This is a different waiting mechanism that uses
** the native timestamp type of the clock rather
** than converting it to a double (or whatever).
- ** You would think that this would be at least a
+ ** You would think that this would be at least a
** few microseconds faster, but a few tests on my
** PowerBook G4 have proved otherwise. Indeed I loose
** several microseconds using this "optimized" method.
- ** Bizzare.
+ ** Bizarre.
** - darco (8-17-2002)
{
timestamp endtime=get_current_time()+seconds_to_timestamp(length);
while(get_current_time()<endtime);
}
*/
-
+
return;
}
};