X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Ftiming%2Ftimestamp.hxx;h=ac9ca1423fe81b56041b4a49ce2e146b5d6cb662;hb=5af8bb7c8e259f5bdda67beb87adcc453e0b32e7;hp=f195dc3740fbdedd4593b2d6c9ff6f574a648494;hpb=f06f25532ca06b7edb948131f45f8efea2268589;p=simgear.git diff --git a/simgear/timing/timestamp.hxx b/simgear/timing/timestamp.hxx index f195dc37..ac9ca142 100644 --- a/simgear/timing/timestamp.hxx +++ b/simgear/timing/timestamp.hxx @@ -184,6 +184,8 @@ public: { 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) @@ -195,6 +197,22 @@ public: 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 */