Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83258 - trunk/boost/thread/win32
From: vicente.botet_at_[hidden]
Date: 2013-03-03 04:45:52


Author: viboes
Date: 2013-03-03 04:45:48 EST (Sun, 03 Mar 2013)
New Revision: 83258
URL: http://svn.boost.org/trac/boost/changeset/83258

Log:
Thread: Make use of GetTickCount64 when available
Text files modified:
   trunk/boost/thread/win32/thread_data.hpp | 10 +++++-----
   trunk/boost/thread/win32/thread_primitives.hpp | 29 +++++++++++++++++++++++++++--
   2 files changed, 32 insertions(+), 7 deletions(-)

Modified: trunk/boost/thread/win32/thread_data.hpp
==============================================================================
--- trunk/boost/thread/win32/thread_data.hpp (original)
+++ trunk/boost/thread/win32/thread_data.hpp 2013-03-03 04:45:48 EST (Sun, 03 Mar 2013)
@@ -165,7 +165,7 @@
 
         struct BOOST_SYMBOL_VISIBLE timeout
         {
- unsigned long start;
+ win32::ticks_type start;
             uintmax_t milliseconds;
             bool relative;
             boost::system_time abs_time;
@@ -173,14 +173,14 @@
             static unsigned long const max_non_infinite_wait=0xfffffffe;
 
             timeout(uintmax_t milliseconds_):
- start(win32::GetTickCount()),
+ start(win32::GetTickCount64()),
                 milliseconds(milliseconds_),
                 relative(true),
                 abs_time(boost::get_system_time())
             {}
 
             timeout(boost::system_time const& abs_time_):
- start(win32::GetTickCount()),
+ start(win32::GetTickCount64()),
                 milliseconds(0),
                 relative(false),
                 abs_time(abs_time_)
@@ -205,8 +205,8 @@
                 }
                 else if(relative)
                 {
- unsigned long const now=win32::GetTickCount();
- unsigned long const elapsed=now-start;
+ win32::ticks_type const now=win32::GetTickCount64();
+ win32::ticks_type const elapsed=now-start;
                     return remaining_time((elapsed<milliseconds)?(milliseconds-elapsed):0);
                 }
                 else

Modified: trunk/boost/thread/win32/thread_primitives.hpp
==============================================================================
--- trunk/boost/thread/win32/thread_primitives.hpp (original)
+++ trunk/boost/thread/win32/thread_primitives.hpp 2013-03-03 04:45:48 EST (Sun, 03 Mar 2013)
@@ -17,6 +17,12 @@
 #include <boost/detail/interlocked.hpp>
 #include <algorithm>
 
+#ifndef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
+#if WINNT >= 0x0600
+#define BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
+#endif
+#endif
+
 #if defined( BOOST_USE_WINDOWS_H )
 # include <windows.h>
 
@@ -26,6 +32,11 @@
     {
         namespace win32
         {
+#ifdef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
+ typedef unsigned long long ticks_type;
+#else
+ typedef unsigned long ticks_type;
+#endif
             typedef ULONG_PTR ulong_ptr;
             typedef HANDLE handle;
             unsigned const infinite=INFINITE;
@@ -61,6 +72,11 @@
             using ::Sleep;
             using ::QueueUserAPC;
             using ::GetTickCount;
+#ifdef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
+ using ::GetTickCount64;
+#else
+ inline ticks_type GetTickCount64() { return GetTickCount(); }
+#endif
         }
     }
 }
@@ -88,13 +104,18 @@
 # endif
 # endif
 
+
 namespace boost
 {
     namespace detail
     {
         namespace win32
         {
-
+#ifdef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
+ typedef unsigned long long ticks_type;
+#else
+ typedef unsigned long ticks_type;
+#endif
 # ifdef _WIN64
             typedef unsigned __int64 ulong_ptr;
 # else
@@ -133,7 +154,11 @@
                 __declspec(dllimport) unsigned long __stdcall QueueUserAPC(queue_user_apc_callback_function,void*,ulong_ptr);
 
                 __declspec(dllimport) unsigned long __stdcall GetTickCount();
-
+#ifdef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
+ __declspec(dllimport) ticks_type __stdcall GetTickCount64();
+#else
+ inline ticks_type GetTickCount64() { return GetTickCount(); }
+#endif
 # ifndef UNDER_CE
                 __declspec(dllimport) unsigned long __stdcall GetCurrentProcessId();
                 __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId();


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk