PeanutButter
Loading...
Searching...
No Matches
PeanutButter.Utils.ParallelWorker< T > Class Template Reference

Encapsulates some work which must be run in parallel. More...

Inheritance diagram for PeanutButter.Utils.ParallelWorker< T >:
PeanutButter.Utils.Worker PeanutButter.Utils.IParallelWorker< T >

Public Member Functions

 ParallelWorker (params Func< T >[] workers)
 Provide some workers up-front.
void AddWorker (Func< T > worker)
 Add a single worker.
void AddWorkers (IEnumerable< Func< T > > workers)
 Add a bunch of workers.
WorkResult< T >[] RunAll ()
 Run all the queued work with the default max degree of parallelism.
WorkResult< T >[] RunAll (int maxDegreeOfParallelism)
 Run all the queued work with the provided max degree of parallelism.

Properties

bool Busy [get]
 Will be true whilst the worker is busy.
Properties inherited from PeanutButter.Utils.Worker
int DefaultMaxDegreeOfParallelism = Environment.ProcessorCount [get, set]
 Indicates the default MaxDegreeOfParallelism for ParallelWorker (should default to the number of available cores, on the assumption that workloads are more often cpu-bound than I/O-bound).

Detailed Description

Encapsulates some work which must be run in parallel.

Template Parameters
T

Member Function Documentation

◆ AddWorker()

void PeanutButter.Utils.ParallelWorker< T >.AddWorker ( Func< T > worker)

Add a single worker.

Parameters
worker

Implements PeanutButter.Utils.IParallelWorker< T >.

◆ AddWorkers()

void PeanutButter.Utils.ParallelWorker< T >.AddWorkers ( IEnumerable< Func< T > > workers)

Add a bunch of workers.

Parameters
workers

Implements PeanutButter.Utils.IParallelWorker< T >.

◆ ParallelWorker()

PeanutButter.Utils.ParallelWorker< T >.ParallelWorker ( params Func< T >[] workers)

Provide some workers up-front.

Parameters
workers

◆ RunAll() [1/2]

Run all the queued work with the default max degree of parallelism.

Returns

Implements PeanutButter.Utils.IParallelWorker< T >.

◆ RunAll() [2/2]

WorkResult< T >[] PeanutButter.Utils.ParallelWorker< T >.RunAll ( int maxDegreeOfParallelism)

Run all the queued work with the provided max degree of parallelism.

Parameters
maxDegreeOfParallelism
Returns
Exceptions
InvalidOperationException

Implements PeanutButter.Utils.IParallelWorker< T >.

Property Documentation

◆ Busy

Will be true whilst the worker is busy.

Implements PeanutButter.Utils.IParallelWorker< T >.


The documentation for this class was generated from the following file:
  • source/Utils/PeanutButter.Utils/ParallelWorker.cs