Search Results for

    Show / Hide Table of Contents

    Class TaskDirector

    A simple control mechanism for distributed TaskBase work across the thread pool. Tasks should be short-lived and can queue up additional work.

    Inheritance
    System.Object
    TaskDirector
    Namespace: GDX.Threading
    Syntax
    public static class TaskDirector

    Fields

    | Improve this Doc View Source

    exceptionOccured

    An event invoked when a TaskBase throws an exception.

    Declaration
    public static Action<Exception> exceptionOccured
    Field Value
    Type Description
    System.Action<System.Exception>
    | Improve this Doc View Source

    inputBlocked

    An event invoked during Tick() when user input should be blocked.

    Declaration
    public static Action<bool> inputBlocked
    Field Value
    Type Description
    System.Action<System.Boolean>
    | Improve this Doc View Source

    logAdded

    An event invoked during Tick() with new log content.

    Declaration
    public static Action<string[]> logAdded
    Field Value
    Type Description
    System.Action<System.String[]>

    Methods

    | Improve this Doc View Source

    GetBusyCount()

    The number of tasks currently in process or awaiting execution by the thread pool.

    Declaration
    public static int GetBusyCount()
    Returns
    Type Description
    System.Int32

    The number of tasks sitting in GDX.Threading.TaskDirector.k_TasksBusy.

    | Improve this Doc View Source

    GetQueueCount()

    The number of tasks waiting in the queue.

    Declaration
    public static int GetQueueCount()
    Returns
    Type Description
    System.Int32

    The number of tasks sitting in GDX.Threading.TaskDirector.k_TasksQueue.

    | Improve this Doc View Source

    GetStatus()

    Get the status message for the TaskDirector.

    Declaration
    public static string GetStatus()
    Returns
    Type Description
    System.String

    A pre-formatted status message.

    | Improve this Doc View Source

    HasTasks()

    Does the TaskDirector have any known busy or queued tasks?

    Declaration
    public static bool HasTasks()
    Returns
    Type Description
    System.Boolean

    A true/false value indicating tasks.

    Remarks

    It's not performant to poll this.

    | Improve this Doc View Source

    IsBlockingBit(Int32)

    Is the TaskDirector blocking tasks with a specific bit?

    Declaration
    public static bool IsBlockingBit(int index)
    Parameters
    Type Name Description
    System.Int32 index
    Returns
    Type Description
    System.Boolean

    A true/false value indicating if a BitArray16 index is being blocked.

    Remarks

    It isn't ideal to constantly poll this method, ideally this could be used to block things outside of the TaskDirector's control based on tasks running.

    | Improve this Doc View Source

    Log(String)

    Adds a thread-safe log entry to a queue which will be dispatched to logAdded on the Tick() invoking thread.

    Declaration
    public static void Log(string message)
    Parameters
    Type Name Description
    System.String message

    The log content.

    | Improve this Doc View Source

    QueueTask(TaskBase)

    Add a task to the queue, to be later started when possible.

    Declaration
    public static void QueueTask(TaskBase task)
    Parameters
    Type Name Description
    TaskBase task

    An established task.

    Remarks

    If the task is already executing it will be added to the known busy list.

    | Improve this Doc View Source

    Tick()

    Update the TaskDirector, evaluating known tasks for work eligibility and execution.

    Declaration
    public static void Tick()
    Remarks

    This should occur on the main thread. If the TaskDirector is used during play mode, something needs to call this every global tick. While in edit mode the EditorTaskDirector triggers this method.

    | Improve this Doc View Source

    UpdateTask(TaskBase)

    Evaluate the provided task and update its state inside of the TaskDirector.

    Declaration
    public static void UpdateTask(TaskBase task)
    Parameters
    Type Name Description
    TaskBase task

    An established task.

    Remarks

    This will add a task to the TaskDirector if it does not already know about it, regardless of the current blocking mode status. Do not use this method to add non executing tasks, they will not be added to the TaskDirector in this way.

    | Improve this Doc View Source

    Wait()

    Wait on the completion of all known tasks, blocking the invoking thread.

    Declaration
    public static void Wait()
    Remarks

    Useful to force the main thread to wait for completion of tasks.

    | Improve this Doc View Source

    WaitAsync()

    Asynchronously wait on the completion of all known tasks.

    Declaration
    public static async Task WaitAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task
    • Improve this Doc
    • View Source
    In This Article
    Back to top Built on 2024-01-01 against 1f69a68.
    Generated by Dox+DocFX.