|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r71934 - in trunk/boost/chrono: . detail/inlined/posix
From: vicente.botet_at_[hidden]
Date: 2011-05-14 03:42:31
Author: viboes
Date: 2011-05-14 03:42:29 EDT (Sat, 14 May 2011)
New Revision: 71934
URL: http://svn.boost.org/trac/boost/changeset/71934
Log:
Use of CLOCK_THREAD_CPUTIME_ID when defined
Text files modified:
trunk/boost/chrono/config.hpp | 4 ++++
trunk/boost/chrono/detail/inlined/posix/thread_clock.hpp | 6 +++++-
trunk/boost/chrono/duration.hpp | 2 +-
3 files changed, 10 insertions(+), 2 deletions(-)
Modified: trunk/boost/chrono/config.hpp
==============================================================================
--- trunk/boost/chrono/config.hpp (original)
+++ trunk/boost/chrono/config.hpp 2011-05-14 03:42:29 EDT (Sat, 14 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: 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-14 03:42:29 EDT (Sat, 14 May 2011)
@@ -44,14 +44,18 @@
}
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 ) )
+#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))
{
Modified: trunk/boost/chrono/duration.hpp
==============================================================================
--- trunk/boost/chrono/duration.hpp (original)
+++ trunk/boost/chrono/duration.hpp 2011-05-14 03:42:29 EDT (Sat, 14 May 2011)
@@ -430,7 +430,7 @@
public:
BOOST_CHRONO_CONSTEXPR
- duration() : rep_(duration_values<rep>::zero()) { }
+ duration() : rep_(duration_values<rep>::zero()) { }
template <class Rep2>
BOOST_CHRONO_CONSTEXPR
explicit duration(const Rep2& r
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