|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r71951 - trunk/boost/chrono/detail/inlined/posix
From: vicente.botet_at_[hidden]
Date: 2011-05-15 04:18:25
Author: viboes
Date: 2011-05-15 04:18:23 EDT (Sun, 15 May 2011)
New Revision: 71951
URL: http://svn.boost.org/trac/boost/changeset/71951
Log:
Use of CLOCK_THREAD_CPUTIME_ID when defined
Text files modified:
trunk/boost/chrono/detail/inlined/posix/thread_clock.hpp | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
Modified: trunk/boost/chrono/detail/inlined/posix/thread_clock.hpp
==============================================================================
--- trunk/boost/chrono/detail/inlined/posix/thread_clock.hpp (original)
+++ trunk/boost/chrono/detail/inlined/posix/thread_clock.hpp 2011-05-15 04:18:23 EDT (Sun, 15 May 2011)
@@ -21,6 +21,10 @@
thread_clock::time_point thread_clock::now( )
{
+#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
@@ -29,6 +33,7 @@
// 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,9 +49,9 @@
}
thread_clock::time_point thread_clock::now( system::error_code & ec )
{
- struct timespec ts;
#if defined CLOCK_THREAD_CPUTIME_ID
- if ( ::clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts ) )
+ // 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();
@@ -54,6 +59,7 @@
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-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