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

queries the partition type (dynamic)

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

default constructor

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

construct a dynamic partitioner with the given chunk size

tf::DynamicPartitioner< C >::DynamicPartitioner
(size_t sz, C &&closure)
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 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 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::DynamicPartitioner< C >
tf::IsPartitioner
tf::PartitionerBase< DefaultClosureWrapper >
- tf::DynamicPartitioner
  _chunk_size
- tf::DynamicPartitioner
  _closure_wrapper
- tf::DynamicPartitioner
  chunk_size
- tf::DynamicPartitioner
  chunk_size
- tf::DynamicPartitioner
  closure_wrapper
- tf::DynamicPartitioner
  closure_wrapper
- tf::DynamicPartitioner
  closure_wrapper_type
- tf::DynamicPartitioner
  DynamicPartitioner
- tf::DynamicPartitioner
  DynamicPartitioner
- tf::DynamicPartitioner
  DynamicPartitioner
- tf::DynamicPartitioner
  loop
- tf::DynamicPartitioner
  loop_until
- tf::DynamicPartitioner
  PartitionerBase
- tf::DynamicPartitioner
  PartitionerBase
- tf::DynamicPartitioner
  PartitionerBase
- tf::DynamicPartitioner
  type