PeanutButter
Loading...
Searching...
No Matches
PeanutButter.Utils.ParallelWorker Class Reference

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

Inheritance diagram for PeanutButter.Utils.ParallelWorker:
PeanutButter.Utils.Worker PeanutButter.Utils.IParallelWorker 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.

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.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.

Constructor & Destructor Documentation

◆ ParallelWorker()

PeanutButter.Utils.ParallelWorker.ParallelWorker ( params Action[] workers)

Provide some initial work.

Parameters
workers

Member Function Documentation

◆ AddWorker()

void PeanutButter.Utils.ParallelWorker.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.

◆ AddWorkers()

void PeanutButter.Utils.ParallelWorker.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.

◆ RunAll() [1/2]

Exception[] PeanutButter.Utils.ParallelWorker.RunAll ( )

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

Returns

Implements PeanutButter.Utils.IParallelWorker.

◆ RunAll() [2/2]

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

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

Returns

Implements PeanutButter.Utils.IParallelWorker.

Property Documentation

◆ Busy

bool PeanutButter.Utils.ParallelWorker.Busy
get

Will be true whilst the worker is busy.

Implements PeanutButter.Utils.IWorker.


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