Cpp-Taskflow  2.1.0
tf::SpeculativeThreadpool< Closure > Class Template Reference

Executor that implements a centralized task queue with a speculative execution strategy. More...

#include <speculative_threadpool.hpp>

Public Member Functions

 SpeculativeThreadpool (unsigned N)
 constructs the executor with a given number of worker threads More...
 
 ~SpeculativeThreadpool ()
 destructs the executor More...
 
size_t num_workers () const
 queries the number of worker threads
 
bool is_owner () const
 queries if the caller is the owner of the executor
 
template<typename... ArgsT>
void emplace (ArgsT &&... args)
 constructs the closure in place in the executor More...
 
void batch (std::vector< Closure > &&closures)
 moves a batch of closures to the executor More...
 

Detailed Description

template<typename Closure>
class tf::SpeculativeThreadpool< Closure >

Executor that implements a centralized task queue with a speculative execution strategy.

Template Parameters
Closureclosure type

Constructor & Destructor Documentation

◆ SpeculativeThreadpool()

template<typename Closure >
tf::SpeculativeThreadpool< Closure >::SpeculativeThreadpool ( unsigned  N)

constructs the executor with a given number of worker threads

Parameters
Nthe number of worker threads

◆ ~SpeculativeThreadpool()

template<typename Closure >
tf::SpeculativeThreadpool< Closure >::~SpeculativeThreadpool ( )

destructs the executor

Destructing the executor immediately forces all worker threads to stop. The executor does not guarantee all tasks to finish upon destruction.

Member Function Documentation

◆ batch()

template<typename Closure >
void tf::SpeculativeThreadpool< Closure >::batch ( std::vector< Closure > &&  closures)

moves a batch of closures to the executor

Parameters
closuresa vector of closures to move

◆ emplace()

template<typename Closure >
template<typename... ArgsT>
void tf::SpeculativeThreadpool< Closure >::emplace ( ArgsT &&...  args)

constructs the closure in place in the executor

Template Parameters
ArgsT...argument parameter pack
Parameters
args...arguments to forward to the constructor of the closure

The documentation for this class was generated from the following file: