tf::WorkerInterface
taskflow/core/worker.hpp
virtual tf::WorkerInterface::~WorkerInterface
()=default
~WorkerInterface
tf::WorkerInterface::~WorkerInterface

default destructor

void virtual void tf::WorkerInterface::scheduler_prologue (Worker &worker)=0 scheduler_prologue tf::WorkerInterface::scheduler_prologue Worker & worker

method to call before a worker enters the scheduling loop

worker

a reference to the worker

The method is called by the constructor of an executor.
void virtual void tf::WorkerInterface::scheduler_epilogue (Worker &worker, std::exception_ptr ptr)=0 scheduler_epilogue tf::WorkerInterface::scheduler_epilogue Worker & worker std::exception_ptr ptr

method to call after a worker leaves the scheduling loop

worker

a reference to the worker

ptr

an pointer to the exception thrown by the scheduling loop

The method is called by the constructor of an executor.

class to configure worker behavior in an executor

The tf::WorkerInterface class allows users to customize worker properties when creating an executor. Examples include binding workers to specific CPU cores or invoking custom methods before and after a worker enters or leaves the work-stealing loop. When you create an executor, it spawns a set of workers to execute tasks with the following logic:

    for(size_tn=0;n<num_workers;n++){
    create_thread([](Worker&worker)

    //pre-processingexecutor-specificworkerinformation
    //...

    //entertheschedulingloop
    //Here,WorkerInterface::scheduler_prologueisinvoked,ifany
    worker_interface->scheduler_prologue(worker);

    try{
    while(1){
    perform_work_stealing_algorithm();
    if(stop){
    break;
    }
    }
    }catch(...){
    exception_ptr=std::current_exception();
    }

    //leavestheschedulingloopandjoinsthisworkerthread
    //Here,WorkerInterface::scheduler_epilogueisinvoked,ifany
    worker_interface->scheduler_epilogue(worker,exception_ptr);
    );
    }

tf::WorkerInterface::scheduler_prologue and tf::WorkerInterface::scheduler_eiplogue are invoked by each worker simultaneously.

- tf::WorkerInterface
  scheduler_epilogue
- tf::WorkerInterface
  scheduler_prologue
- tf::WorkerInterface
  ~WorkerInterface