Commit 00cbb5e7 authored by Joseph Noir's avatar Joseph Noir

Fix to use caf thread header

parent fc5a1ed8
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
#define CAF_CACHE_LINE_SIZE 64 #define CAF_CACHE_LINE_SIZE 64
#include <thread>
#include <atomic> #include <atomic>
#include <cassert> #include <cassert>
#include "caf/chrono.hpp" #include "caf/chrono.hpp"
#include "caf/thread.hpp"
// GCC hack // GCC hack
#if defined(CAF_GCC) && !defined(_GLIBCXX_USE_SCHED_YIELD) #if defined(CAF_GCC) && !defined(_GLIBCXX_USE_SCHED_YIELD)
...@@ -233,7 +233,7 @@ class double_ended_queue { ...@@ -233,7 +233,7 @@ class double_ended_queue {
public: public:
lock_guard(std::atomic_flag& lock) : m_lock(lock) { lock_guard(std::atomic_flag& lock) : m_lock(lock) {
while (lock.test_and_set(std::memory_order_acquire)) { while (lock.test_and_set(std::memory_order_acquire)) {
std::this_thread::yield(); this_thread::yield();
} }
} }
~lock_guard() { ~lock_guard() {
......
...@@ -20,10 +20,11 @@ ...@@ -20,10 +20,11 @@
#ifndef CAF_SCHEDULER_COORDINATOR_HPP #ifndef CAF_SCHEDULER_COORDINATOR_HPP
#define CAF_SCHEDULER_COORDINATOR_HPP #define CAF_SCHEDULER_COORDINATOR_HPP
#include <thread>
#include <limits> #include <limits>
#include <memory> #include <memory>
#include <condition_variable>
#include "caf/thread.hpp"
#include "caf/condition_variable.hpp"
#include "caf/scheduler/worker.hpp" #include "caf/scheduler/worker.hpp"
#include "caf/scheduler/abstract_coordinator.hpp" #include "caf/scheduler/abstract_coordinator.hpp"
...@@ -41,7 +42,7 @@ class coordinator : public abstract_coordinator { ...@@ -41,7 +42,7 @@ class coordinator : public abstract_coordinator {
using policy_data = typename Policy::coordinator_data; using policy_data = typename Policy::coordinator_data;
coordinator(size_t nw = std::max(std::thread::hardware_concurrency(), 4u), coordinator(size_t nw = std::max(thread::hardware_concurrency(), 4u),
size_t mt = std::numeric_limits<size_t>::max()) size_t mt = std::numeric_limits<size_t>::max())
: super(nw), : super(nw),
m_max_throughput(mt) { m_max_throughput(mt) {
...@@ -139,7 +140,7 @@ class coordinator : public abstract_coordinator { ...@@ -139,7 +140,7 @@ class coordinator : public abstract_coordinator {
} }
private: private:
// usually of size std::thread::hardware_concurrency() // usually of size thread::hardware_concurrency()
std::vector<std::unique_ptr<worker_type>> m_workers; std::vector<std::unique_ptr<worker_type>> m_workers;
// policy-specific data // policy-specific data
policy_data m_data; policy_data m_data;
......
...@@ -53,7 +53,7 @@ class worker : public execution_unit { ...@@ -53,7 +53,7 @@ class worker : public execution_unit {
void start() { void start() {
CAF_ASSERT(m_this_thread.get_id() == std::thread::id{}); CAF_ASSERT(m_this_thread.get_id() == std::thread::id{});
auto this_worker = this; auto this_worker = this;
m_this_thread = std::thread{[this_worker] { m_this_thread = thread{[this_worker] {
CAF_LOGF_TRACE("id = " << this_worker->id()); CAF_LOGF_TRACE("id = " << this_worker->id());
this_worker->run(); this_worker->run();
}}; }};
...@@ -91,7 +91,7 @@ class worker : public execution_unit { ...@@ -91,7 +91,7 @@ class worker : public execution_unit {
return m_id; return m_id;
} }
std::thread& get_thread() { thread& get_thread() {
return m_this_thread; return m_this_thread;
} }
...@@ -155,7 +155,7 @@ class worker : public execution_unit { ...@@ -155,7 +155,7 @@ class worker : public execution_unit {
// number of messages each actor is allowed to consume per resume // number of messages each actor is allowed to consume per resume
size_t m_max_throughput; size_t m_max_throughput;
// the worker's thread // the worker's thread
std::thread m_this_thread; thread m_this_thread;
// the worker's ID received from scheduler // the worker's ID received from scheduler
size_t m_id; size_t m_id;
// pointer to central coordinator // pointer to central coordinator
......
...@@ -20,9 +20,10 @@ ...@@ -20,9 +20,10 @@
#ifndef CAF_SET_SCHEDULER_HPP #ifndef CAF_SET_SCHEDULER_HPP
#define CAF_SET_SCHEDULER_HPP #define CAF_SET_SCHEDULER_HPP
#include <thread>
#include <limits> #include <limits>
#include "caf/thread.hpp"
#include "caf/policy/work_stealing.hpp" #include "caf/policy/work_stealing.hpp"
#include "caf/scheduler/worker.hpp" #include "caf/scheduler/worker.hpp"
...@@ -48,7 +49,7 @@ void set_scheduler(scheduler::abstract_coordinator* ptr); ...@@ -48,7 +49,7 @@ void set_scheduler(scheduler::abstract_coordinator* ptr);
* @throws std::invalid_argument if `max_throughput == 0` * @throws std::invalid_argument if `max_throughput == 0`
*/ */
template <class Policy = policy::work_stealing> template <class Policy = policy::work_stealing>
void set_scheduler(size_t nw = std::thread::hardware_concurrency(), void set_scheduler(size_t nw = thread::hardware_concurrency(),
size_t max_throughput = std::numeric_limits<size_t>::max()) { size_t max_throughput = std::numeric_limits<size_t>::max()) {
if (max_throughput == 0) { if (max_throughput == 0) {
throw std::invalid_argument("max_throughput must not be 0"); throw std::invalid_argument("max_throughput must not be 0");
......
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
#define CAF_SUITE unpublish #define CAF_SUITE unpublish
#include "caf/test/unit_test.hpp" #include "caf/test/unit_test.hpp"
#include <thread>
#include <atomic> #include <atomic>
#include "caf/all.hpp" #include "caf/all.hpp"
#include "caf/thread.hpp"
#include "caf/io/all.hpp" #include "caf/io/all.hpp"
using namespace caf; using namespace caf;
......
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