Back to Taskflow

tf::Worker class

docs/classtf_1_1Worker.html

4.0.01.2 KB
Original Source

tf::Worker class

class to create a worker in an executor

The class is primarily used by the executor to perform work-stealing algorithm. Users can access a worker object and alter its property (e.g., changing the thread affinity in a POSIX-like system) using tf::WorkerInterface.

Public functions

auto id() const -> size_tqueries the worker id associated with its parent executorauto queue_size() const -> size_tqueries the size of the queue (i.e., number of enqueued tasks to run) associated with the workerauto queue_capacity() const -> size_tqueries the current capacity of the queueauto thread() -> std::thread&acquires the associated thread

Function documentation

size_t tf::Worker::id() const

queries the worker id associated with its parent executor

A worker id is a unsigned integer in the range [0, N), where N is the number of workers spawned at the construction time of the executor.