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 > PeanutButter.Utils.Worker PeanutButter.Utils.IParallelWorker< T > PeanutButter.Utils.IWorker PeanutButter.Utils.IWorker

Public Member Functions

 ParallelWorker (params Action[] workers)
 Provide some initial work.
 
void AddWorkers (IEnumerable< Action > workers)
 Add some workers to the queue. If the work is already running, they will be added to the end and executed when the queue is complete.
 
Exception[] RunAll ()
 Run all the queued work with the default max degree of parallelism.
 
Exception[] RunAll (int maxDegreeOfParallelism)
 Run all the queued work with the provided max degree of parallelism.
 
void AddWorker (Action worker)
 Add a single worker to the queue. If the work is already running, it will be added to the end and executed when the queue is complete.
 
 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).
 
- Properties inherited from PeanutButter.Utils.IParallelWorker< T >
- Properties inherited from PeanutButter.Utils.IWorker
int DefaultMaxDegreeOfParallelism [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

Constructor & Destructor Documentation

◆ ParallelWorker() [1/2]

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

Provide some initial work.

Parameters
workers

◆ ParallelWorker() [2/2]

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

Provide some workers up-front.

Parameters
workers

Member Function Documentation

◆ AddWorker() [1/2]

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

Add a single worker to the queue. If the work is already running, it will be added to the end and executed when the queue is complete.

Parameters
worker

Implements PeanutButter.Utils.IParallelWorker< T >.

◆ AddWorker() [2/2]

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

Add a single worker.

Parameters
worker

Implements PeanutButter.Utils.IParallelWorker< T >.

◆ AddWorkers() [1/2]

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

Add some workers to the queue. If the work is already running, they will be added to the end and executed when the queue is complete.

Parameters
workers

Implements PeanutButter.Utils.IParallelWorker< T >.

◆ AddWorkers() [2/2]

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

Add a bunch of workers.

Parameters
workers

Implements PeanutButter.Utils.IParallelWorker< T >.

◆ RunAll() [1/4]

Exception[] PeanutButter.Utils.ParallelWorker< T >.RunAll ( )

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

Returns

Implements PeanutButter.Utils.IParallelWorker< T >.

◆ RunAll() [2/4]

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

Returns

Implements PeanutButter.Utils.IParallelWorker< T >.

◆ RunAll() [3/4]

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

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

Returns

Implements PeanutButter.Utils.IParallelWorker< T >.

◆ RunAll() [4/4]

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: