Go to the documentation of this file.
29 #include <ArmarXCore/interface/core/TimeServerInterface.h>
31 #include <IceUtil/Time.h>
72 #ifndef BOOST_NO_CXX11_HDR_CHRONO
73 #define GENERATE_TIME_OPERATOR_COMP(op)\
74 template<class Rep, class Period>\
75 inline bool operator op(IceUtil::Time a, std::chrono::duration<Rep, Period> b)\
77 return a.toMicroSeconds() op std::chrono::duration_cast<std::chrono::microseconds>(b).count();\
79 template<class Rep, class Period>\
80 inline bool operator op(std::chrono::duration<Rep, Period> a, IceUtil::Time b)\
82 return std::chrono::duration_cast<std::chrono::microseconds>(a).count() op b.toMicroSeconds();\
90 #undef GENERATE_TIME_OPERATOR_COMP
91 #define GENERATE_TIME_OPERATORS_ARITH(op)\
92 template<class Rep, class Period>\
93 inline IceUtil::Time operator op(IceUtil::Time a, std::chrono::duration<Rep, Period> b)\
95 return a op IceUtil::Time::microSeconds(std::chrono::duration_cast<std::chrono::microseconds>(b).count());\
97 template<class Rep, class Period>\
98 inline IceUtil::Time operator op(std::chrono::duration<Rep, Period> a, IceUtil::Time b)\
100 return IceUtil::Time::microSeconds(std::chrono::duration_cast<std::chrono::microseconds>(a).count()) op b;\
106 #undef GENERATE_TIME_OPERATORS_ARITH
110 class LocalTimeServer;
169 bool forceSystemTime);
185 template<
class Rep,
class Period>
186 static void Sleep(std::chrono::duration<Rep, Period> d)
188 Sleep(IceUtil::Time::microSeconds(std::chrono::duration_cast<std::chrono::microseconds>(d).count()));
193 Sleep(IceUtil::Time::microSeconds(
int(1000000 * seconds)));
197 Sleep(IceUtil::Time::microSeconds(
int(1000 * milliseconds)));
201 Sleep(IceUtil::Time::microSeconds(
int(microseconds)));
208 static void MSSleep(
int durationMS);
241 static int USleep(
long usec);
280 #define TIMING_START(name) auto name = IceUtil::Time::now();
284 #define TIMING_END_COMMENT_STREAM(name, comment, os) \
286 name = (IceUtil::Time::now() - name); \
287 os << deactivateSpam(1, comment) << comment << " - duration: " << name.toMilliSecondsDouble() << " ms"; \
292 #define TIMING_END_COMMENT(name, comment) TIMING_END_COMMENT_STREAM(name, comment, ARMARX_INFO)
296 #define TIMING_END(name) TIMING_END_COMMENT(name, #name)
300 #define TIMING_END_STREAM(name, os) TIMING_END_COMMENT_STREAM(name, #name, os)
305 #define TIMING_CEND_COMMENT(name, comment, thresholdMs) if((IceUtil::Time::now()-name).toMilliSecondsDouble() >= thresholdMs) TIMING_END_COMMENT(name, comment)
309 #define TIMING_CEND(name, thresholdMs) TIMING_CEND_COMMENT(name, #name, thresholdMs)
static void SleepUS(float microseconds)
static std::string toStringTime(const IceUtil::Time &time)
Return a time string like "15-30-05" (H-M-S).
static std::string toStringDate(const IceUtil::Time &time)
Return a date string like "2020-01-31" (Y-M-D).
static std::string toStringDateTime(const IceUtil::Time &time)
Return a date & time string like "2020-01-31_15-30-05" (Y-M-D_H-M-S).
static void MSSleep(int durationMS)
lock the calling thread for a given duration (like usleep(...) but using Timeserver time)
static void Sleep(std::chrono::duration< Rep, Period > d)
lock the calling thread for a given duration (like usleep(...) but using Timeserver time)
static int NanoSleep(long usec)
Nanosleep convenience function.
static LocalTimeServerPtr GetTimeServer()
IceInternal::Handle< LocalTimeServer > LocalTimeServerPtr
static LocalTimeServerPtr timeServerPtr
pointer to the applications LocalTimeServer if NULL, system time is used
static int USleep(long usec)
like timed_wait on boost condition_variables, but with timeserver support
static void Sleep(float seconds)
provides utility functions for getting the current time
static bool HasTimeServer()
check if we have been initialized with a Timeserver
static void Sleep(IceUtil::Time duration)
lock the calling thread for a given duration (like usleep(...) but using Timeserver time)
armarx::core::time::DateTime Time
static void WaitForNextTick()
block until the next tick of the timeserver.
static IceUtil::Time GetTime(TimeMode timeMode=TimeMode::VirtualTime)
Get the current time.
#define GENERATE_TIME_OPERATOR_COMP(op)
TimeMode
Time mode to be used.
static IceUtil::Time GetTimeSince(IceUtil::Time referenceTime, TimeMode timeMode=TimeMode::VirtualTime)
Get the difference between the current time and a reference time.
static void SetTimeServer(LocalTimeServerPtr ts)
static void SleepMS(float milliseconds)
#define GENERATE_TIME_OPERATORS_ARITH(op)
This file offers overloads of toIce() and fromIce() functions for STL container types.