chsvlib
chsv helper source code

◆ ForEachRowSetPolicy()

void ForEachRowSetPolicy ( FunctorType &&  fn,
Args...  args 
) const

Performs parallel policy-based enumeration of rows of a matrix calling a client's Callable object.

Template Parameters
FunctorTypeA type of the client's Callable object, i.e. A function, a pointer to function, a method, a lambda, etc. Since ForEachRowSetPolicy passes an additional argument to the callable, the type cannot be a class data member. See fn description for the requirements.
Args...A type pack of additional arguments passed directly to the callable object starting from the second parameter position. See fn description below.
ParallelismPolicyA policy marker specifying whether the enumeration should be performed in multiply CPU threads. Possible values are matrix_always_sequential and matrix_always_parallel (but not matrix_dynamically_customizable_parallelism).
Parameters
fnis a Callable object passed to the method by a client. The object, of type FunctorType, is expected to process the rows independently of one another both in parallel and in sequential mode, since the order of calls to the object is unspecified. The scheme of calling the object is given in the description of Callable. Additionally, the first parameter passed by the implementation of ForEachRowSetPolicy to fn is an index if a column to process. I.e. the calls are made in the following forms.
std::forward<FunctorType>(fn)(iRow, std::forward<Args>(args)...); //for a function object
(std::forward<Arg1>(arg1).*fn)(iRow, std::forward<Args2_n>(args2_n)...); //for a pointer to a method of a class object arg1 of type Arg1 where
//Arg1 is the first type of the pack Args, arg1 is the corresponding parameter; Args2_n - types of the pack Args excluding the first one, args2_n
//is a corresponding pack of arguments.
(arg1.get().*fn)(iRow, std::forward<Args2_n>(args2_n)...); //The same, but if Arg1 is std::reference_wrapper
Here iRow is an index of a row being enumerated, and args is a pack of parameters given by the client as the second parameter of the ForEachRowSetPolicy method with respect to the Args type pack. The integral iRow is of the size_type type.
argsis a parameter pack for the callable fn defined by the client.

Unlike ForEachRow, the method enumerates rows of the matrix using a specifically provided policy.

Exceptions
std::system_errorAny of the parallel threads could not be started.