summaryrefslogtreecommitdiff
path: root/src/mongo/util
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2012-07-14 18:07:40 -0400
committerEliot Horowitz <eliot@10gen.com>2012-07-14 18:07:40 -0400
commit11513316d1bdc9ad9e8a19746fb7a04c15f78b3b (patch)
treefe4ff886ae6c7dee4c32b304881c0a2e2325cb2d /src/mongo/util
parent5665ee8b85d600c0720cb1e12774f5a660afa456 (diff)
downloadmongo-11513316d1bdc9ad9e8a19746fb7a04c15f78b3b.tar.gz
SERVER-6449 - decide which BOSOT::TIME_UTC variant to use at compile time
Diffstat (limited to 'src/mongo/util')
-rw-r--r--src/mongo/util/background.cpp2
-rw-r--r--src/mongo/util/concurrency/mutex.h3
-rw-r--r--src/mongo/util/queue.h4
-rw-r--r--src/mongo/util/time_support.cpp16
-rw-r--r--src/mongo/util/time_support.h7
5 files changed, 20 insertions, 12 deletions
diff --git a/src/mongo/util/background.cpp b/src/mongo/util/background.cpp
index 5ae9c441213..f1c89633268 100644
--- a/src/mongo/util/background.cpp
+++ b/src/mongo/util/background.cpp
@@ -92,7 +92,7 @@ namespace mongo {
if ( msTimeOut ) {
// add msTimeOut millisecond to current time
boost::xtime xt;
- boost::xtime_get( &xt, boost::TIME_UTC_ );
+ boost::xtime_get( &xt, MONGO_BOOST_TIME_UTC );
unsigned long long ns = msTimeOut * 1000000ULL; // milli to nano
if ( xt.nsec + ns < 1000000000 ) {
diff --git a/src/mongo/util/concurrency/mutex.h b/src/mongo/util/concurrency/mutex.h
index acbc3983710..024efd7be16 100644
--- a/src/mongo/util/concurrency/mutex.h
+++ b/src/mongo/util/concurrency/mutex.h
@@ -28,6 +28,7 @@
#include "mongo/util/assert_util.h"
#include "mongo/util/heapcheck.h"
#include "mongo/util/concurrency/threadlocal.h"
+#include "mongo/util/time_support.h"
#if defined(_DEBUG)
#include "mongo/util/concurrency/mutexdebugger.h"
@@ -37,7 +38,7 @@ namespace mongo {
inline boost::xtime incxtimemillis( long long s ) {
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC_);
+ boost::xtime_get(&xt, MONGO_BOOST_TIME_UTC);
xt.sec += (int)( s / 1000 );
xt.nsec += (int)(( s % 1000 ) * 1000000);
if ( xt.nsec >= 1000000000 ) {
diff --git a/src/mongo/util/queue.h b/src/mongo/util/queue.h
index 581eb722e61..7c8ba288114 100644
--- a/src/mongo/util/queue.h
+++ b/src/mongo/util/queue.h
@@ -121,7 +121,7 @@ namespace mongo {
Timer timer;
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC_);
+ boost::xtime_get(&xt, MONGO_BOOST_TIME_UTC);
xt.sec += maxSecondsToWait;
scoped_lock l( _lock );
@@ -143,7 +143,7 @@ namespace mongo {
Timer timer;
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC_);
+ boost::xtime_get(&xt, MONGO_BOOST_TIME_UTC);
xt.sec += maxSecondsToWait;
scoped_lock l( _lock );
diff --git a/src/mongo/util/time_support.cpp b/src/mongo/util/time_support.cpp
index 7391ea1fe94..0021c577c3b 100644
--- a/src/mongo/util/time_support.cpp
+++ b/src/mongo/util/time_support.cpp
@@ -106,7 +106,7 @@ namespace mongo {
if ( s <= 0 )
return;
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC_);
+ boost::xtime_get(&xt, MONGO_BOOST_TIME_UTC);
xt.sec += (int)( s / 1000000 );
xt.nsec += (int)(( s % 1000000 ) * 1000);
if ( xt.nsec >= 1000000000 ) {
@@ -118,13 +118,13 @@ namespace mongo {
#elif defined(__sunos__)
void sleepsecs(int s) {
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC_);
+ boost::xtime_get(&xt, MONGO_BOOST_TIME_UTC);
xt.sec += s;
boost::thread::sleep(xt);
}
void sleepmillis(long long s) {
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC_);
+ boost::xtime_get(&xt, MONGO_BOOST_TIME_UTC);
xt.sec += (int)( s / 1000 );
xt.nsec += (int)(( s % 1000 ) * 1000000);
if ( xt.nsec >= 1000000000 ) {
@@ -137,7 +137,7 @@ namespace mongo {
if ( s <= 0 )
return;
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC_);
+ boost::xtime_get(&xt, MONGO_BOOST_TIME_UTC);
xt.sec += (int)( s / 1000000 );
xt.nsec += (int)(( s % 1000000 ) * 1000);
if ( xt.nsec >= 1000000000 ) {
@@ -202,24 +202,24 @@ namespace mongo {
#ifdef _WIN32 // no gettimeofday on windows
unsigned long long curTimeMillis64() {
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC_);
+ boost::xtime_get(&xt, MONGO_BOOST_TIME_UTC);
return ((unsigned long long)xt.sec) * 1000 + xt.nsec / 1000000;
}
Date_t jsTime() {
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC_);
+ boost::xtime_get(&xt, MONGO_BOOST_TIME_UTC);
unsigned long long t = xt.nsec / 1000000;
return ((unsigned long long) xt.sec * 1000) + t + getJSTimeVirtualSkew() + getJSTimeVirtualThreadSkew();
}
unsigned long long curTimeMicros64() {
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC_);
+ boost::xtime_get(&xt, MONGO_BOOST_TIME_UTC);
unsigned long long t = xt.nsec / 1000;
return (((unsigned long long) xt.sec) * 1000000) + t;
}
unsigned curTimeMicros() {
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC_);
+ boost::xtime_get(&xt, MONGO_BOOST_TIME_UTC);
unsigned t = xt.nsec / 1000;
unsigned secs = xt.sec % 1024;
return secs*1000000 + t;
diff --git a/src/mongo/util/time_support.h b/src/mongo/util/time_support.h
index 33662c8e4b9..511bc092fb1 100644
--- a/src/mongo/util/time_support.h
+++ b/src/mongo/util/time_support.h
@@ -19,6 +19,7 @@
#include <ctime>
#include <string>
+#include <boost/thread/xtime.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "mongo/bson/util/misc.h" // Date_t
@@ -62,4 +63,10 @@ namespace mongo {
struct tm *gmtime(const time_t *timep);
struct tm *localtime(const time_t *timep);
+#if defined(MONGO_BOOST_TIME_UTC_HACK) || (BOOST_VERSION >= 105000)
+#define MONGO_BOOST_TIME_UTC boost::TIME_UTC_
+#else
+#define MONGO_BOOST_TIME_UTC boost::TIME_UTC
+#endif
+
} // namespace mongo