3#include "declarations.hpp"
5#include "nonblocking_notifier.hpp"
6#include "atomic_notifier.hpp"
35#ifdef TF_ENABLE_ATOMIC_NOTIFIER
72 inline size_t id()
const {
return _id; }
88 std::thread&
thread() {
return _thread; }
92 alignas(TF_CACHELINE_SIZE) std::atomic_flag _done = ATOMIC_FLAG_INIT;
95 size_t _sticky_victim;
152inline WorkerView::WorkerView(
const Worker& w) : _worker{w} {
162 return _worker._wsq.
size();
167 return static_cast<size_t>(_worker._wsq.
capacity());
313template <
typename T,
typename... ArgsT>
316 std::is_base_of_v<WorkerInterface, T>,
317 "T must be derived from WorkerInterface"
319 return std::make_shared<T>(std::forward<ArgsT>(args)...);
constexpr size_t capacity() const
queries the capacity of the queue
Definition wsq.hpp:1074
size_t size() const noexcept
queries the number of items at the time of this call
Definition wsq.hpp:933
class to create an executor
Definition executor.hpp:62
class to create a non-blocking notifier
Definition nonblocking_notifier.hpp:84
class to create a runtime task
Definition runtime.hpp:47
class to configure worker behavior in an executor
Definition worker.hpp:275
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
class to create an immutable view of a worker
Definition worker.hpp:116
size_t id() const
queries the worker id associated with its parent executor
Definition worker.hpp:156
size_t queue_capacity() const
queries the current capacity of the queue
Definition worker.hpp:166
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:161
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:72
size_t queue_capacity() const
queries the current capacity of the queue
Definition worker.hpp:83
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:78
std::thread & thread()
acquires the associated thread
Definition worker.hpp:88
class to create a fast xorshift-based pseudo-random number generator
Definition math.hpp:320
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:314
NonblockingNotifier DefaultNotifier
the default notifier type used by Taskflow
Definition worker.hpp:38