template<typename C = DefaultClosureWrapper>
tf::GuidedPartitioner class

class to construct a guided partitioner for scheduling parallel algorithms

Template parameters
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::Taskflow taskflow;
taskflow.for_each_index(0, 100, 1, 
  [](){                 
    printf("%d\n", i); 
  },
  tf::GuidedPartitioner(0, [](auto&& closure){
    // do something before invoking the partitioned task
    // ...
    
    // invoke the partitioned task
    closure();

    // do something else after invoking the partitioned task
    // ...
  }
);
executor.run(taskflow).wait();

Base classes

template<typename C = DefaultClosureWrapper>
class PartitionerBase<DefaultClosureWrapper>
class to derive a partitioner for scheduling parallel algorithms

Public static functions

static auto type() -> PartitionerType constexpr
queries the partition type (dynamic)

Constructors, destructors, conversion operators

GuidedPartitioner() defaulted
default constructor
GuidedPartitioner(size_t sz) explicit
construct a guided partitioner with the given chunk size
GuidedPartitioner(size_t sz, C&& closure) explicit
construct a guided partitioner with the given chunk size and the closure