Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72239 - in branches/release/boost/chrono: . detail/inlined/posix
From: vicente.botet_at_[hidden]
Date: 2011-05-28 03:02:21


Author: viboes
Date: 2011-05-28 03:02:19 EDT (Sat, 28 May 2011)
New Revision: 72239
URL: http://svn.boost.org/trac/boost/changeset/72239

Log:
Chrono: Merge #5543 and #5549
Text files modified:
   branches/release/boost/chrono/config.hpp | 4 ++++
   branches/release/boost/chrono/detail/inlined/posix/thread_clock.hpp | 14 ++++++++++++--
   2 files changed, 16 insertions(+), 2 deletions(-)

Modified: branches/release/boost/chrono/config.hpp
==============================================================================
--- branches/release/boost/chrono/config.hpp (original)
+++ branches/release/boost/chrono/config.hpp 2011-05-28 03:02:19 EDT (Sat, 28 May 2011)
@@ -62,6 +62,10 @@
 # define BOOST_CHRONO_HAS_THREAD_CLOCK
 # define BOOST_CHRONO_THREAD_CLOCK_IS_STEADY true
 # endif
+# if defined(CLOCK_THREAD_CPUTIME_ID) && !defined(BOOST_DISABLE_THREADS)
+# define BOOST_CHRONO_HAS_THREAD_CLOCK
+# define BOOST_CHRONO_THREAD_CLOCK_IS_STEADY true
+# endif
 # endif
 
 #if defined(BOOST_CHRONO_THREAD_DISABLED) && defined(BOOST_CHRONO_HAS_THREAD_CLOCK)

Modified: branches/release/boost/chrono/detail/inlined/posix/thread_clock.hpp
==============================================================================
--- branches/release/boost/chrono/detail/inlined/posix/thread_clock.hpp (original)
+++ branches/release/boost/chrono/detail/inlined/posix/thread_clock.hpp 2011-05-28 03:02:19 EDT (Sat, 28 May 2011)
@@ -21,14 +21,19 @@
 
     thread_clock::time_point thread_clock::now( )
     {
+ struct timespec ts;
+#if defined CLOCK_THREAD_CPUTIME_ID
+ // get the timespec associated to the thread clock
+ if ( ::clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts ) )
+#else
         // get the current thread
         pthread_t pth=pthread_self();
         // get the clock_id associated to the current thread
         clockid_t clock_id;
         pthread_getcpuclockid(pth, &clock_id);
         // get the timespec associated to the thread clock
- struct timespec ts;
         if ( ::clock_gettime( clock_id, &ts ) )
+#endif
         {
             boost::throw_exception(
                     system::system_error(
@@ -44,14 +49,19 @@
     }
     thread_clock::time_point thread_clock::now( system::error_code & ec )
     {
+ struct timespec ts;
+#if defined CLOCK_THREAD_CPUTIME_ID
+ // get the timespec associated to the thread clock
+ if ( ::clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts ) )
+#else
         // get the current thread
         pthread_t pth=pthread_self();
         // get the clock_id associated to the current thread
         clockid_t clock_id;
         pthread_getcpuclockid(pth, &clock_id);
         // get the timespec associated to the thread clock
- struct timespec ts;
         if ( ::clock_gettime( clock_id, &ts ) )
+#endif
         {
             if (BOOST_CHRONO_IS_THROWS(ec))
             {


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