summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/sys/Time.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2006-11-29 14:36:08 +0000
committerAlan Conway <aconway@apache.org>2006-11-29 14:36:08 +0000
commitb13e1a24fcca8797b7be5a242f164afbe17ec4f6 (patch)
treeef0362e52c125bc75b07ef3e374dabfa52254e98 /cpp/src/qpid/sys/Time.cpp
parent16d818e749462daf5e0e43079b2e48991646c619 (diff)
downloadqpid-python-b13e1a24fcca8797b7be5a242f164afbe17ec4f6.tar.gz
Posix EventChannel implementation using epoll. Placeholder for kevents.
Dynamic thread pool EventChannelThreads to serve EventChannel. Misc cleanup/enhancements. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@480582 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/Time.cpp')
-rw-r--r--cpp/src/qpid/sys/Time.cpp39
1 files changed, 18 insertions, 21 deletions
diff --git a/cpp/src/qpid/sys/Time.cpp b/cpp/src/qpid/sys/Time.cpp
index 3971297ec2..ad6185b966 100644
--- a/cpp/src/qpid/sys/Time.cpp
+++ b/cpp/src/qpid/sys/Time.cpp
@@ -27,37 +27,34 @@ namespace sys {
// APR ================================================================
#if USE_APR
-Time Time::now() {
- return Time(apr_time_now(), NSEC_PER_USEC);
-}
-
-void Time::set(int64_t ticks, long nsec_per_tick) {
- time = (ticks * nsec_per_tick) / NSEC_PER_USEC;
-}
-
-int64_t Time::nsecs() const {
- return time * NSEC_PER_USEC;
-}
+Time now() { return apr_time_now() * TIME_USEC; }
// POSIX================================================================
#else
-Time Time::now() {
- Time t;
- clock_gettime(CLOCK_REALTIME, &t.time);
- return t;
+Time now() {
+ struct timespec ts;
+ clock_gettime(CLOCK_REALTIME, &ts);
+ return toTime(ts);
+}
+
+struct timespec toTimespec(const Time& t) {
+ struct timespec ts;
+ toTimespec(ts, t);
+ return ts;
}
-void Time::set(int64_t ticks, long nsec_per_tick) {
- int64_t ns = ticks * nsec_per_tick;
- time.tv_sec = ns / NSEC_PER_SEC;
- time.tv_nsec = ns % NSEC_PER_SEC;
+struct timespec& toTimespec(struct timespec& ts, const Time& t) {
+ ts.tv_sec = t / TIME_SEC;
+ ts.tv_nsec = t % TIME_SEC;
+ return ts;
}
-int64_t Time::nsecs() const {
- return time.tv_sec * NSEC_PER_SEC + time.tv_nsec;
+Time toTime(const struct timespec& ts) {
+ return ts.tv_sec*TIME_SEC + ts.tv_nsec;
}
+
#endif
}}