diff options
| author | Andrew Stitcher <astitcher@apache.org> | 2010-04-23 03:59:52 +0000 |
|---|---|---|
| committer | Andrew Stitcher <astitcher@apache.org> | 2010-04-23 03:59:52 +0000 |
| commit | fbbda16ce5d06ebebc7d6eabdbd0769a3d886cb8 (patch) | |
| tree | 7243947a60c12915121bb3f6b21fc40c7d4af72c /cpp/include/qpid/sys | |
| parent | 0251793e6387b741424787ae4902994fd2f46e9f (diff) | |
| download | qpid-python-fbbda16ce5d06ebebc7d6eabdbd0769a3d886cb8.tar.gz | |
QPID-1904: Ensure that all timestamp uses are correctly relative to 1/1/1970 epoch.
- Removed the hacky way to access the internal time value in AbsTime now that there
is a defined AbsTime value EPOCH.
- Changed all the code to use Duration(EPOCH, abtime)
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@937147 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/include/qpid/sys')
| -rw-r--r-- | cpp/include/qpid/sys/Time.h | 16 | ||||
| -rw-r--r-- | cpp/include/qpid/sys/posix/Condition.h | 2 |
2 files changed, 6 insertions, 12 deletions
diff --git a/cpp/include/qpid/sys/Time.h b/cpp/include/qpid/sys/Time.h index f798baadfe..d3ab832229 100644 --- a/cpp/include/qpid/sys/Time.h +++ b/cpp/include/qpid/sys/Time.h @@ -58,20 +58,15 @@ class Duration; * accessors to its internal state. If you think you want to replace its value, * you need to construct a new AbsTime and assign it, viz: * - * AbsTime when = AbsTime::now(); + * AbsTime when = now(); * ... * when = AbsTime(when, 2*TIME_SEC); // Advance timer 2 secs * - * If for some reason you need access to the internal nanosec value you need - * to convert the AbsTime to a Duration and use its conversion to int64_t, viz: + * AbsTime is not intended to be used to represent calendar dates/times + * but you can construct a Duration since the Unix Epoch, 1970-1-1-00:00, + * so that you can convert to a date/time if needed: * - * AbsTime now = AbsTime::now(); - * - * int64_t ns = Duration(now); - * - * However note that the nanosecond value that is returned here is not - * defined to be anything in particular and could vary from platform to - * platform. + * int64_t nanosec_since_epoch = Duration(EPOCH, now()); * * There are some sensible operations that are currently missing from * AbsTime, but nearly all that's needed can be done with a mixture of @@ -125,7 +120,6 @@ class Duration { public: QPID_COMMON_EXTERN inline Duration(int64_t time0 = 0); - QPID_COMMON_EXTERN explicit Duration(const AbsTime& time0); QPID_COMMON_EXTERN explicit Duration(const AbsTime& start, const AbsTime& finish); inline operator int64_t() const; }; diff --git a/cpp/include/qpid/sys/posix/Condition.h b/cpp/include/qpid/sys/posix/Condition.h index 279039735a..36e7557ffd 100644 --- a/cpp/include/qpid/sys/posix/Condition.h +++ b/cpp/include/qpid/sys/posix/Condition.h @@ -65,7 +65,7 @@ void Condition::wait(Mutex& mutex) { bool Condition::wait(Mutex& mutex, const AbsTime& absoluteTime){ struct timespec ts; - toTimespec(ts, Duration(absoluteTime)); + toTimespec(ts, Duration(EPOCH, absoluteTime)); int status = pthread_cond_timedwait(&condition, &mutex.mutex, &ts); if (status != 0) { if (status == ETIMEDOUT) return false; |
