3#include "declarations.hpp"
5#include "nonblocking_notifier.hpp"
6#include "atomic_notifier.hpp"
35#ifdef TF_ENABLE_ATOMIC_NOTIFIER
57 friend class Executor;
59 friend class WorkerView;
61#ifdef TF_ENABLE_TASK_PRIORITY
76 inline size_t id()
const {
return _id; }
87 inline size_t queue_capacity()
const {
return static_cast<size_t>(_wsq.capacity()); }
92 std::thread&
thread() {
return _thread; }
96 alignas(TF_CACHELINE_SIZE) std::atomic_flag _done = ATOMIC_FLAG_INIT;
99 size_t _sticky_victim;
121 friend class Executor;
147 WorkerView(
const Worker&);
148 WorkerView(
const WorkerView&) =
default;
154inline WorkerView::WorkerView(
const Worker& w) : _worker{w} {
164 return _worker.queue_size();
169 return _worker.queue_capacity();
315template <
typename T,
typename... ArgsT>
318 std::is_base_of_v<WorkerInterface, T>,
319 "T must be derived from WorkerInterface"
321 return std::make_shared<T>(std::forward<ArgsT>(args)...);
class to create a lock-free bounded work-stealing queue with priority support
Definition wsq.hpp:983
class to create a lock-free bounded work-stealing queue
Definition wsq.hpp:559
class to create a non-blocking notifier
Definition nonblocking_notifier.hpp:84
class to configure worker behavior in an executor
Definition worker.hpp:277
virtual void scheduler_epilogue(Worker &worker, std::exception_ptr ptr)=0
method to call after a worker leaves the scheduling loop
virtual void scheduler_prologue(Worker &worker)=0
method to call before a worker enters the scheduling loop
virtual ~WorkerInterface()=default
default destructor
size_t id() const
queries the worker id associated with its parent executor
Definition worker.hpp:158
size_t queue_capacity() const
queries the current capacity of the queue
Definition worker.hpp:168
size_t queue_size() const
queries the size of the queue (i.e., number of pending tasks to run) associated with the worker
Definition worker.hpp:163
class to create a worker in an executor
Definition worker.hpp:55
size_t id() const
queries the worker id associated with its parent executor
Definition worker.hpp:76
size_t queue_capacity() const
queries the current capacity of the queue
Definition worker.hpp:87
size_t queue_size() const
queries the size of the queue (i.e., number of enqueued tasks to run) associated with the worker
Definition worker.hpp:82
std::thread & thread()
acquires the associated thread
Definition worker.hpp:92
class to create a fast xorshift-based pseudo-random number generator
Definition math.hpp:412
taskflow namespace
Definition small_vector.hpp:20
std::shared_ptr< T > make_worker_interface(ArgsT &&... args)
helper function to create an instance derived from tf::WorkerInterface
Definition worker.hpp:316
NonblockingNotifier DefaultNotifier
the default notifier type used by Taskflow
Definition worker.hpp:38