* level of accuracy).
*
* The SGTimeStamp is useful for tracking the elapsed time of various
- * events in your program. You can also use it to keep constistant
+ * events in your program. You can also use it to keep consistent
* motion across varying frame rates.
*
* Note SGTimestamp does not deliver the time of day. The content of this
{ SGTimeStamp ts; ts.setTime(sec); return ts; }
static SGTimeStamp fromSec(const double& sec)
{ SGTimeStamp ts; ts.setTime(sec); return ts; }
+ static SGTimeStamp fromMSec(nsec_type msec)
+ { return SGTimeStamp(0, 1000*1000*msec); }
static SGTimeStamp fromUSec(nsec_type usec)
{ return SGTimeStamp(0, 1000*usec); }
static SGTimeStamp fromNSec(nsec_type nsec)
static SGTimeStamp now()
{ SGTimeStamp ts; ts.stamp(); return ts; }
+ /**
+ * Sleep until the time of abstime is passed.
+ */
+ static bool sleepUntil(const SGTimeStamp& abstime);
+
+ /**
+ * Sleep for reltime.
+ */
+ static bool sleepFor(const SGTimeStamp& reltime);
+
+ /**
+ * Alias for the most common use case with milliseconds.
+ */
+ static bool sleepForMSec(unsigned msec)
+ { return sleepFor(fromMSec(msec)); }
+
+ /**
+ * elapsed time since the stamp was taken, in msec
+ */
+ int elapsedMSec() const;
private:
SGTimeStamp(sec_type sec, nsec_type nsec)
{ setTime(sec, nsec); }