diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2015-06-11 19:18:40 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2015-06-16 10:36:48 -0400 |
commit | 8c877b35e44e15fe2ccaf564103571a7bef728bc (patch) | |
tree | 741180d576334b205b9452d1cfbac2e1ded59034 /src/mongo/util/time_support.cpp | |
parent | b06861044ad1610cef2f2fa8a9e24e5b72ee7345 (diff) | |
download | mongo-8c877b35e44e15fe2ccaf564103571a7bef728bc.tar.gz |
SERVER-6686 Remove remaining uses of boost::xtime.
Also, remove curTimeMicros() which could not represent times since it cannot
represent points in time after 1970-01-01T00:01:11:34.967
Diffstat (limited to 'src/mongo/util/time_support.cpp')
-rw-r--r-- | src/mongo/util/time_support.cpp | 51 |
1 files changed, 8 insertions, 43 deletions
diff --git a/src/mongo/util/time_support.cpp b/src/mongo/util/time_support.cpp index 07759e890ba..e72158f7e0c 100644 --- a/src/mongo/util/time_support.cpp +++ b/src/mongo/util/time_support.cpp @@ -32,24 +32,16 @@ #include <cstdio> #include <string> #include <iostream> -#include <boost/thread/thread.hpp> #include <boost/thread/tss.hpp> -#include <boost/thread/xtime.hpp> -#include <boost/version.hpp> #include "mongo/base/init.h" #include "mongo/base/parse_number.h" #include "mongo/bson/util/builder.h" #include "mongo/platform/cstdint.h" +#include "mongo/stdx/thread.h" #include "mongo/util/assert_util.h" #include "mongo/util/mongoutils/str.h" -#if BOOST_VERSION >= 105000 -#define MONGO_BOOST_TIME_UTC boost::TIME_UTC_ -#else -#define MONGO_BOOST_TIME_UTC boost::TIME_UTC -#endif - #ifdef _WIN32 #include <boost/date_time/filetime_functions.hpp> #include "mongo/util/concurrency/mutex.h" @@ -801,24 +793,14 @@ namespace { #if defined(_WIN32) void sleepsecs(int s) { - Sleep(s*1000); + stdx::this_thread::sleep_for(Seconds(s)); } + void sleepmillis(long long s) { - fassert(16228, s <= 0xffffffff ); - Sleep((DWORD) s); + stdx::this_thread::sleep_for(Milliseconds(s)); } void sleepmicros(long long s) { - if ( s <= 0 ) - return; - boost::xtime xt; - boost::xtime_get(&xt, MONGO_BOOST_TIME_UTC); - xt.sec += (int)( s / 1000000 ); - xt.nsec += (int)(( s % 1000000 ) * 1000); - if ( xt.nsec >= 1000000000 ) { - xt.nsec -= 1000000000; - xt.sec++; - } - boost::thread::sleep(xt); + stdx::this_thread::sleep_for(Microseconds(s)); } #else void sleepsecs(int s) { @@ -920,15 +902,11 @@ namespace { Milliseconds(getJSTimeVirtualSkew()); } - /** warning this will wrap */ - unsigned curTimeMicros(); - - unsigned long long curTimeMicros64(); #ifdef _WIN32 // no gettimeofday on windows unsigned long long curTimeMillis64() { - boost::xtime xt; - boost::xtime_get(&xt, MONGO_BOOST_TIME_UTC); - return ((unsigned long long)xt.sec) * 1000 + xt.nsec / 1000000; + using stdx::chrono::system_clock; + return static_cast<unsigned long long>( + durationCount<Milliseconds>(system_clock::now() - system_clock::from_time_t(0))); } static unsigned long long getFiletime() { @@ -1026,13 +1004,6 @@ namespace { return boost::date_time::winapi::file_time_to_microseconds(computedTime); } - unsigned curTimeMicros() { - boost::xtime xt; - boost::xtime_get(&xt, MONGO_BOOST_TIME_UTC); - unsigned t = xt.nsec / 1000; - unsigned secs = xt.sec % 1024; - return secs*1000000 + t; - } #else #include <sys/time.h> unsigned long long curTimeMillis64() { @@ -1046,12 +1017,6 @@ namespace { gettimeofday(&tv, NULL); return (((unsigned long long) tv.tv_sec) * 1000*1000) + tv.tv_usec; } - unsigned curTimeMicros() { - timeval tv; - gettimeofday(&tv, NULL); - unsigned secs = tv.tv_sec % 1024; - return secs*1000*1000 + tv.tv_usec; - } #endif } // namespace mongo |