diff options
author | Marcel Smit <msmit@remedy.nl> | 2015-02-17 11:36:39 +0100 |
---|---|---|
committer | Marcel Smit <msmit@remedy.nl> | 2015-02-17 11:36:39 +0100 |
commit | 6b0b5ff56e74519ac6ba2efe84f9592344337ab7 (patch) | |
tree | a84f7bcce2e1e4789ce5a9b05464144b646ac3d3 /ACE/ace | |
parent | f9fcd61495af961bd34032cd43919b4b6e0615d2 (diff) | |
download | ATCD-6b0b5ff56e74519ac6ba2efe84f9592344337ab7.tar.gz |
Added chono support for sleeps and ACE_Time_Values.
* ACE/ace/OS_NS_unistd.h:
* ACE/ace/OS_NS_unistd.inl:
* ACE/ace/Time_Value.h:
* ACE/ace/Time_Value.inl:
Diffstat (limited to 'ACE/ace')
-rw-r--r-- | ACE/ace/OS_NS_unistd.h | 4 | ||||
-rw-r--r-- | ACE/ace/OS_NS_unistd.inl | 9 | ||||
-rw-r--r-- | ACE/ace/Time_Value.h | 6 | ||||
-rw-r--r-- | ACE/ace/Time_Value.inl | 13 |
4 files changed, 32 insertions, 0 deletions
diff --git a/ACE/ace/OS_NS_unistd.h b/ACE/ace/OS_NS_unistd.h index 20a81571e1f..fb8bb452052 100644 --- a/ACE/ace/OS_NS_unistd.h +++ b/ACE/ace/OS_NS_unistd.h @@ -295,6 +295,10 @@ namespace ACE_OS ACE_NAMESPACE_INLINE_FUNCTION int sleep (const ACE_Time_Value &tv); + template< class Rep, class Period > + ACE_NAMESPACE_INLINE_FUNCTION + int sleep (const std::chrono::duration<Rep, Period>& duration); + // used by ARGV::string_to_argv extern ACE_Export int string_to_argv (ACE_TCHAR *buf, diff --git a/ACE/ace/OS_NS_unistd.inl b/ACE/ace/OS_NS_unistd.inl index 6bcc6f72547..54a42385c88 100644 --- a/ACE/ace/OS_NS_unistd.inl +++ b/ACE/ace/OS_NS_unistd.inl @@ -964,6 +964,15 @@ ACE_OS::sleep (const ACE_Time_Value &tv) #endif /* ACE_WIN32 */ } +template< class Rep, class Period > +ACE_INLINE int +ACE_OS::sleep (const std::chrono::duration<Rep, Period>& duration) +{ + ACE_OS_TRACE ("ACE_OS::sleep"); + return ACE_OS::sleep (ACE_Time_Value (duration)); +} + + ACE_INLINE void ACE_OS::swab (const void *src, void *dest, diff --git a/ACE/ace/Time_Value.h b/ACE/ace/Time_Value.h index bb0351c97be..375c5f2828d 100644 --- a/ACE/ace/Time_Value.h +++ b/ACE/ace/Time_Value.h @@ -20,6 +20,8 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ # include "ace/os_include/os_time.h" +// TODO move this. +#include <chrono> // Define some helpful constants. // Not type-safe, and signed. For backward compatibility. @@ -78,6 +80,10 @@ public: /// Construct the ACE_Time_Value object from a timespec_t. explicit ACE_Time_Value (const timespec_t &t); + /// Construct the ACE_Time_Value object from a chrono duration. + template< class Rep, class Period > + explicit ACE_Time_Value (const std::chrono::duration<Rep, Period>& duration); + /// Destructor virtual ~ACE_Time_Value (); diff --git a/ACE/ace/Time_Value.inl b/ACE/ace/Time_Value.inl index eaed073f45d..ae767e16ea2 100644 --- a/ACE/ace/Time_Value.inl +++ b/ACE/ace/Time_Value.inl @@ -96,6 +96,19 @@ ACE_Time_Value::ACE_Time_Value (void) this->set (0, 0); } +template< class Rep, class Period > +ACE_INLINE +ACE_Time_Value::ACE_Time_Value (const std::chrono::duration<Rep, Period>& duration) +{ + std::chrono::seconds const s { + std::chrono::duration_cast<std::chrono::seconds> (duration)}; + + std::chrono::microseconds const usec { + std::chrono::duration_cast<std::chrono::microseconds>( + duration % std::chrono::seconds (1))}; + this->set (s.count (), usec.count ()); +} + ACE_INLINE ACE_Time_Value::ACE_Time_Value (time_t sec, suseconds_t usec) { |