Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    Scheduler Class

    Namespace: Stride.Core.MicroThreading
    Assembly: Stride.Core.MicroThreading.dll

    Scheduler that manage a group of cooperating MicroThread.

    System.Object → Scheduler
    Derived from Scheduler:

    public class Scheduler
    Remarks

    Microthreading provides a way to execute many small execution contexts who cooperatively yield to each others.

    Name Description
    Constructors
    Scheduler()

    Initializes a new instance of the Scheduler class.

    Properties
    Current

    Gets the scheduler associated with current micro thread.

    CurrentMicroThread

    Gets the current micro thread (self).

    FrameChannel
    MicroThreads

    Gets the list of every non-stopped micro threads.

    RunningMicroThread

    Gets the current running micro thread in this scheduler through Run().

    Methods
    Add(Func<Task>, MicroThreadFlags)

    Creates a micro thread out of the specified function and schedules it as last micro thread to run in this scheduler. Note that in case of multithreaded scheduling, it might start before this function returns.

    Create()

    Creates a new empty micro thread, that could later be started with Start(Func<Task>, ScheduleMode).

    NextFrame()

    Yields execution until next frame.

    Run()

    Runs until no runnable tasklets left. This function is reentrant.

    WhenAll(MicroThread[])

    Task that will completes when all MicroThread executions are completed.

    Yield()

    Yields execution. If any other micro thread is pending, it will be run now and current micro thread will be scheduled as last.

    Events
    MicroThreadCallbackEnd
    MicroThreadCallbackStart
    MicroThreadEnded
    MicroThreadStarted
    | Improve this Doc View Source

    Constructors


    Scheduler()

    Initializes a new instance of the Scheduler class.

    public Scheduler()
    | Improve this Doc View Source

    Properties


    Current

    Gets the scheduler associated with current micro thread.

    public static Scheduler Current { get; }
    Property Value
    Type Description
    Scheduler

    The scheduler associated with current micro thread.


    CurrentMicroThread

    Gets the current micro thread (self).

    public static MicroThread CurrentMicroThread { get; }
    Property Value
    Type Description
    MicroThread

    The current micro thread (self).


    FrameChannel

    protected Channel<int> FrameChannel { get; }
    Property Value
    Type Description
    Channel<System.Int32>

    MicroThreads

    Gets the list of every non-stopped micro threads.

    public ICollection<MicroThread> MicroThreads { get; }
    Property Value
    Type Description
    System.Collections.Generic.ICollection<MicroThread>

    The list of every non-stopped micro threads.


    RunningMicroThread

    Gets the current running micro thread in this scheduler through Run().

    public MicroThread RunningMicroThread { get; }
    Property Value
    Type Description
    MicroThread

    The current running micro thread in this scheduler.

    | Improve this Doc View Source

    Methods


    Add(Func<Task>, MicroThreadFlags)

    Creates a micro thread out of the specified function and schedules it as last micro thread to run in this scheduler. Note that in case of multithreaded scheduling, it might start before this function returns.

    public MicroThread Add(Func<Task> microThreadFunction, MicroThreadFlags flags = MicroThreadFlags.None)
    Parameters
    Type Name Description
    System.Func<System.Threading.Tasks.Task> microThreadFunction

    The function to create a micro thread from.

    MicroThreadFlags flags

    The flags.

    Returns
    Type Description
    MicroThread

    A micro thread.


    Create()

    Creates a new empty micro thread, that could later be started with Start(Func<Task>, ScheduleMode).

    public MicroThread Create()
    Returns
    Type Description
    MicroThread

    A new empty micro thread.


    NextFrame()

    Yields execution until next frame.

    public ChannelMicroThreadAwaiter<int> NextFrame()
    Returns
    Type Description
    ChannelMicroThreadAwaiter<System.Int32>

    Task that will resume next frame.


    Run()

    Runs until no runnable tasklets left. This function is reentrant.

    public void Run()

    WhenAll(MicroThread[])

    Task that will completes when all MicroThread executions are completed.

    public async Task WhenAll(params MicroThread[] microThreads)
    Parameters
    Type Name Description
    MicroThread[] microThreads

    The micro threads.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A task that will complete when all micro threads are complete.


    Yield()

    Yields execution. If any other micro thread is pending, it will be run now and current micro thread will be scheduled as last.

    public static MicroThreadYieldAwaiter Yield()
    Returns
    Type Description
    MicroThreadYieldAwaiter

    Task that will resume later during same frame.

    | Improve this Doc View Source

    Events


    MicroThreadCallbackEnd

    public event EventHandler<SchedulerThreadEventArgs> MicroThreadCallbackEnd
    Event Type
    Type Description
    System.EventHandler<SchedulerThreadEventArgs>

    MicroThreadCallbackStart

    public event EventHandler<SchedulerThreadEventArgs> MicroThreadCallbackStart
    Event Type
    Type Description
    System.EventHandler<SchedulerThreadEventArgs>

    MicroThreadEnded

    public event EventHandler<SchedulerThreadEventArgs> MicroThreadEnded
    Event Type
    Type Description
    System.EventHandler<SchedulerThreadEventArgs>

    MicroThreadStarted

    public event EventHandler<SchedulerThreadEventArgs> MicroThreadStarted
    Event Type
    Type Description
    System.EventHandler<SchedulerThreadEventArgs>

    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation