|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r76300 - trunk/boost/thread/v2
From: vicente.botet_at_[hidden]
Date: 2012-01-03 17:31:12
Author: viboes
Date: 2012-01-03 17:31:11 EST (Tue, 03 Jan 2012)
New Revision: 76300
URL: http://svn.boost.org/trac/boost/changeset/76300
Log:
Thread: Added new v2 files
Added:
trunk/boost/thread/v2/
trunk/boost/thread/v2/thread.hpp (contents, props changed)
Added: trunk/boost/thread/v2/thread.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/thread/v2/thread.hpp 2012-01-03 17:31:11 EST (Tue, 03 Jan 2012)
@@ -0,0 +1,52 @@
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// (C) Copyright 2011 Vicente J. Botet Escriba
+
+#ifndef BOOST_THREAD_V2_THREAD_HPP
+#define BOOST_THREAD_V2_THREAD_HPP
+
+#include <boost/thread/detail/config.hpp>
+#include <boost/chrono/system_clocks.hpp>
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/locks.hpp>
+
+namespace boost
+{
+ namespace this_thread
+ {
+
+ void BOOST_SYMBOL_VISIBLE sleep_for(const chrono::nanoseconds& ns);
+
+ template <class Rep, class Period>
+ void sleep_for(const chrono::duration<Rep, Period>& d)
+ {
+ using namespace chrono;
+ nanoseconds ns = duration_cast<nanoseconds> (d);
+ if (ns < d) ++ns;
+ sleep_for(ns);
+ }
+
+ template <class Clock, class Duration>
+ void sleep_until(const chrono::time_point<Clock, Duration>& t)
+ {
+ using namespace chrono;
+ mutex mut;
+ condition_variable cv;
+ unique_lock<mutex> lk(mut);
+ while (Clock::now() < t)
+ cv.wait_until(lk, t);
+ }
+
+ template <class Duration>
+ inline BOOST_SYMBOL_VISIBLE
+ void sleep_until(const chrono::time_point<chrono::steady_clock, Duration>& t)
+ {
+ using namespace chrono;
+ sleep_for(t - steady_clock::now());
+ }
+ }
+}
+
+
+#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