Class WorkScheduler
The work scheduler class.
Implements
Inherited Members
Namespace: Evergine.Framework.Threading
Assembly: Evergine.Framework.dll
Syntax
public class WorkScheduler : IDisposable
Constructors
WorkScheduler(int)
Initializes a new instance of the WorkScheduler class.
Declaration
public WorkScheduler(int maxThreadCount = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | maxThreadCount | Max threads. |
Fields
Instance
Scheduler static instance.
Declaration
public static readonly WorkScheduler Instance
Field Value
| Type | Description |
|---|---|
| WorkScheduler |
MaxThreadCount
Max thread count.
Declaration
public readonly int MaxThreadCount
Field Value
| Type | Description |
|---|---|
| int |
Properties
StealingEnabled
Gets or sets a value indicating whether the work stealing is enabled.
Declaration
public bool StealingEnabled { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
WorksAvailable
Gets the work available count.
Declaration
public int WorksAvailable { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Dispose()
Public implementation of Dispose pattern callable by consumers.
Declaration
public void Dispose()
Dispose(bool)
Protected implementation of Dispose pattern.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing | Dispose native elements. |
~WorkScheduler()
Finalizes an instance of the WorkScheduler class.
Declaration
protected ~WorkScheduler()
For(int, int, Action<int>, WorkHandle, WorkPriority)
Schedule For works.
Declaration
public WorkHandle For(int fromInclusive, int toExclusive, Action<int> action, WorkHandle parent = null, WorkPriority priority = WorkPriority.Normal)
Parameters
| Type | Name | Description |
|---|---|---|
| int | fromInclusive | The start index. |
| int | toExclusive | The end index. |
| Action<int> | action | The action to execute. |
| WorkHandle | parent | The parent work. |
| WorkPriority | priority | The work priority. |
Returns
| Type | Description |
|---|---|
| WorkHandle | The work handle. |
ForEach<T>(IList<T>, Action<T>, WorkHandle, WorkPriority)
Executes an action on every work.
Declaration
public WorkHandle ForEach<T>(IList<T> list, Action<T> action, WorkHandle parent = null, WorkPriority priority = WorkPriority.Normal)
Parameters
| Type | Name | Description |
|---|---|---|
| IList<T> | list | Work collection list. |
| Action<T> | action | Action to execute. |
| WorkHandle | parent | Parent work. |
| WorkPriority | priority | Work priority. |
Returns
| Type | Description |
|---|---|
| WorkHandle | The work handle. |
Type Parameters
| Name | Description |
|---|---|
| T | Work type. |
ForEach<T>(T[], Action<T>, WorkHandle, WorkPriority)
Executes an action on every work.
Declaration
public WorkHandle ForEach<T>(T[] array, Action<T> action, WorkHandle parent = null, WorkPriority priority = WorkPriority.Normal)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | array | Work collection array. |
| Action<T> | action | Action to execute. |
| WorkHandle | parent | Parent work. |
| WorkPriority | priority | Work priority. |
Returns
| Type | Description |
|---|---|
| WorkHandle | The work handle. |
Type Parameters
| Name | Description |
|---|---|
| T | Work type. |
ResetStats()
Reset the stats of the work scheduler.
Declaration
public void ResetStats()
Schedule(Action, WorkHandle, WorkPriority)
Schedule work.
Declaration
public WorkHandle Schedule(Action workItem, WorkHandle parent = null, WorkPriority priority = WorkPriority.Normal)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | workItem | The action to execute. |
| WorkHandle | parent | The parent task. |
| WorkPriority | priority | The priority. |
Returns
| Type | Description |
|---|---|
| WorkHandle | The work handle. |