Commit 59b0bb35 authored by Joseph Noir's avatar Joseph Noir

Fix clock namespace issue and remove unused code

parent 774b8f16
...@@ -104,7 +104,7 @@ inline bool operator>=(const time_point& lhs, const time_point& rhs) { ...@@ -104,7 +104,7 @@ inline bool operator>=(const time_point& lhs, const time_point& rhs) {
namespace caf { namespace caf {
using time_point = std::chrono::high_resolution_clock::time_point; using time_point = std::chrono::high_resolution_clock::time_point;
inline std::chrono::time_point<std::chrono::high_resolution_clock> now() { inline time_point<std::chrono::high_resolution_clock> now() {
return std::chrono::high_resolution_clock::now(); return std::chrono::high_resolution_clock::now();
} }
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "vtimer.h" #include "vtimer.h"
#include "caf/mutex.hpp" #include "caf/mutex.hpp"
#include "caf/chrono.hpp" #include "caf/chrono.hpp"
...@@ -73,17 +72,6 @@ class condition_variable { ...@@ -73,17 +72,6 @@ class condition_variable {
priority_queue_t m_queue; priority_queue_t m_queue;
}; };
template <class T, class Rep, class Period>
inline typename std::enable_if<std::chrono::__is_duration<T>::value,T>::type
ceil(std::chrono::duration<Rep, Period> duration) {
using namespace std::chrono;
T res = duration_cast<T>(duration);
if (res < duration) {
++res;
}
return res;
}
template <class Predicate> template <class Predicate>
void condition_variable::wait(unique_lock<mutex>& lock, Predicate pred) { void condition_variable::wait(unique_lock<mutex>& lock, Predicate pred) {
while(!pred()) { while(!pred()) {
...@@ -130,8 +118,7 @@ template <class Rep, class Period, class Predicate> ...@@ -130,8 +118,7 @@ template <class Rep, class Period, class Predicate>
inline bool condition_variable::wait_for(unique_lock<mutex>& lock, inline bool condition_variable::wait_for(unique_lock<mutex>& lock,
const std::chrono::duration<Rep, Period>& timeout_duration, const std::chrono::duration<Rep, Period>& timeout_duration,
Predicate pred) { Predicate pred) {
return wait_until(lock, std::chrono::steady_clock::now() + timeout_duration, return wait_until(lock, now() + timeout_duration, std::move(pred));
std::move(pred));
} }
} // namespace caf } // namespace caf
......
...@@ -126,14 +126,14 @@ namespace this_thread { ...@@ -126,14 +126,14 @@ namespace this_thread {
mutex mtx; mutex mtx;
condition_variable cv; condition_variable cv;
unique_lock<mutex> lk(mtx); unique_lock<mutex> lk(mtx);
while(Clock::now() < sleep_time) { while(now() < sleep_time) {
cv.wait_until(lk,sleep_time); cv.wait_until(lk,sleep_time);
} }
} }
template <class Period> template <class Period>
inline void sleep_until(const std::chrono::time_point<std::chrono::steady_clock, inline void sleep_until(const std::chrono::time_point<std::chrono::steady_clock,
Period>& sleep_time) { Period>& sleep_time) {
sleep_for(sleep_time - std::chrono::steady_clock::now()); sleep_for(sleep_time - now());
} }
} // namespace this_thread } // namespace this_thread
......
...@@ -54,10 +54,6 @@ void thread::join() { ...@@ -54,10 +54,6 @@ void thread::join() {
// missing: no_such_process system error // missing: no_such_process system error
} }
void thread::join() {
// you can't join threads
}
void thread::detach() { void thread::detach() {
if (joinable()) { if (joinable()) {
m_handle = thread_uninitialized; m_handle = thread_uninitialized;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment