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

queries the partition type (dynamic)

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

default constructor

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

construct a dynamic partitioner with the given chunk size

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

construct a dynamic 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::DynamicPartitioner< C >::loop (size_t N, size_t, std::atomic< size_t > &next, F &&func) const loop tf::DynamicPartitioner::loop size_t N size_t 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::DynamicPartitioner< C >::loop_until (size_t N, size_t, std::atomic< size_t > &next, F &&func) const loop_until tf::DynamicPartitioner::loop_until size_t N size_t std::atomic< size_t > & next F && func

class to construct a dynamic partitioner for scheduling parallel algorithms

C

closure wrapper type (default tf::DefaultClosureWrapper)

The partitioner splits iterations into many partitions each of size equal to the given chunk size. Different partitions are distributed dynamically to workers without any specific order.

In addition to partition size, the application can specify a closure wrapper for a dynamic 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::DynamicPartitioner(0,[](auto&&closure){
    //dosomethingbeforeinvokingthepartitionedtask
    //...

    //invokethepartitionedtask
    closure();

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

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