tf::GuidedPartitioner
tf::PartitionerBase< DefaultClosureWrapper >
taskflow/algorithm/partitioner.hpp
typename C DefaultClosureWrapper
PartitionerType static constexpr PartitionerType tf::GuidedPartitioner< C >::type () type tf::GuidedPartitioner::type

queries the partition type (dynamic)

tf::GuidedPartitioner< C >::GuidedPartitioner
()=default
GuidedPartitioner
tf::GuidedPartitioner::GuidedPartitioner

default constructor

tf::GuidedPartitioner< C >::GuidedPartitioner
(size_t sz)
GuidedPartitioner
tf::GuidedPartitioner::GuidedPartitioner
size_t sz

construct a guided partitioner with the given chunk size

tf::GuidedPartitioner< C >::GuidedPartitioner
(size_t sz, C &&closure)
GuidedPartitioner
tf::GuidedPartitioner::GuidedPartitioner
size_t sz
C && closure

construct a guided partitioner with the given chunk size and the closure

typename F
std::enable_if_t< std::is_invocable_r_v< void, F, size_t, size_t >, void > * nullptr
void void tf::GuidedPartitioner< C >::loop (size_t N, size_t W, std::atomic< size_t > &next, F &&func) const loop tf::GuidedPartitioner::loop size_t N size_t W std::atomic< size_t > & next F && func
typename F
std::enable_if_t< std::is_invocable_r_v< bool, F, size_t, size_t >, void > * nullptr
void void tf::GuidedPartitioner< C >::loop_until (size_t N, size_t W, std::atomic< size_t > &next, F &&func) const loop_until tf::GuidedPartitioner::loop_until size_t N size_t W std::atomic< size_t > & next F && func

class to construct a guided partitioner for scheduling parallel algorithms

C

closure wrapper type (default tf::DefaultClosureWrapper)

The size of a partition is proportional to the number of unassigned iterations divided by the number of workers, and the size will gradually decrease to the given chunk size. The last partition may be smaller than the chunk size.

In addition to partition size, the application can specify a closure wrapper for a guided partitioner. A closure wrapper allows the application to wrapper a partitioned task (i.e., closure) with a custom function object that performs additional tasks. For example:

    std::atomic<int>count=0;
    tf::Taskflowtaskflow;
    taskflow.for_each_index(0,100,1,
    [](){
    printf("%d\n",i);
    },
    tf::GuidedPartitioner(0,[](auto&&closure){
    //dosomethingbeforeinvokingthepartitionedtask
    //...

    //invokethepartitionedtask
    closure();

    //dosomethingelseafterinvokingthepartitionedtask
    //...
    }
    );
    executor.run(taskflow).wait();

tf::GuidedPartitioner< C >
tf::IsPartitioner
tf::PartitionerBase< DefaultClosureWrapper >
tf::DefaultClosureWrapper
tf::GuidedPartitioner< C >
tf::IsPartitioner
tf::PartitionerBase< DefaultClosureWrapper >
_closure_wrapper
- tf::GuidedPartitioner
  _chunk_size
- tf::GuidedPartitioner
  _closure_wrapper
- tf::GuidedPartitioner
  chunk_size
- tf::GuidedPartitioner
  closure_wrapper
- tf::GuidedPartitioner
  closure_wrapper_type
- tf::GuidedPartitioner
  GuidedPartitioner
- tf::GuidedPartitioner
  GuidedPartitioner
- tf::GuidedPartitioner
  GuidedPartitioner
- tf::GuidedPartitioner
  is_default_wrapper_v
- tf::GuidedPartitioner
  loop
- tf::GuidedPartitioner
  loop_until
- tf::GuidedPartitioner
  operator()
- tf::GuidedPartitioner
  PartitionerBase
- tf::GuidedPartitioner
  type