class · System.Threading.Tasks

Scheduler

public class System.Threading.Tasks.Scheduler : System.Any

Runs tasks on this thread, one at a time: those ready (in order), then the timers that are due; when nothing is ready it sleeps until the next timer.

Kind
class
Namespace
System.Threading.Tasks
Assembly
System.Core
Access
public, static, abstract
Source file
Tasks.ant

Inheritance

Base classes
Any Scheduler

Properties

static property Threaded: bool
#

static read-only

static property Sync: System.Threading.Mutex
#

static read-only

static property Changed: System.Threading.Condition
#

static read-only

static property Sleeping: bool
#

static read-only

Whether a thread sleeps on Changed (read holding Sync).

Methods

static method OnItsThread() -> bool
#

static

Whether the caller is the scheduler's thread (the program's first).

static method Ready(task: System.Threading.Tasks.Task) -> void
#

static

Runs task in its turn (Run()). On another thread (holding Sync): it goes to the scheduler's inbox.

static method Started() -> void
#

static

A Task.Run body starts, and has finished.

static method Finished() -> void
#

static

static method BlockUntil(task: System.Threading.Tasks.Task) -> void
#

static

Waits (another thread than the scheduler's) until task has finished.

static method Soon(task: System.Threading.Tasks.Task) -> void
#

static

Done in its turn (after what is ready now).

static method After(task: System.Threading.Tasks.Task, milliseconds: i32) -> void
#

static

Done after milliseconds.

static method RunUntil(task: System.Threading.Tasks.Task) -> void
#

static

Runs ready tasks and timers until task has finished (or nothing is left that could finish it).

static method Soonest() -> i32
#

static

The timer that is due first.

static method Due(now: i64) -> bool
#

static

Completes the timers whose time has come (the first due first): whether there was one.

static method Timers() -> void
#

static

Completes the timers that are due; when none is, sleeps until the first one. Once threads complete tasks, the sleep is on Changed (a task completed on another thread wakes it): the timer only bounds it.

Private and internal members (12)

private static

static field first: i32
#

private static

static field timers: System.List<System.Threading.Tasks.Task>
#

private static

static field due: System.List<i64>
#

private static

static field threaded: bool
#

private static

Once Task.Run was used: tasks made ready on other threads (under Sync), and how many Task.Run bodies are running.

static field sync: System.Threading.Mutex
#

private static

static field changed: System.Threading.Condition
#

private static

private static

static field running: i32
#

private static

static field sleepers: i32
#

private static

Threads asleep on Changed (under Sync): a change wakes them only if there are some.

static method Sleep() -> void
#

private static

Sleeps on Changed (holding Sync).

static method Drain() -> void
#

private static

Moves what other threads made ready to the ready list.

Inherited members (5)

Source

Scheduler as Larva HIR, decompiled from its Larva HIR.

System.Threading.Tasks.Scheduler.hir
// Runs tasks on this thread, one at a time: those ready (in order), then the timers that are due; when nothing is
// ready it sleeps until the next timer.
public class System.Threading.Tasks.Scheduler : System.Any
{
    static field ready: System.List<System.Threading.Tasks.Task>
    static field first: i32
    static field timers: System.List<System.Threading.Tasks.Task>
    static field due: System.List<i64>
    // Once Task.Run was used: tasks made ready on other threads (under Sync), and how many Task.Run bodies are running.
    static field threaded: bool
    static field sync: System.Threading.Mutex
    static field changed: System.Threading.Condition
    static field inbox: System.List<System.Threading.Tasks.Task>
    static field running: i32
    // Threads asleep on Changed (under Sync): a change wakes them only if there are some.
    static field sleepers: i32
    // Sleeps on Changed (holding Sync).
    static method Sleep() -> void
    // Moves what other threads made ready to the ready list.
    static method Drain() -> void
    // Whether the caller is the scheduler's thread (the program's first).
    static method OnItsThread() -> bool
    // Runs `task` in its turn (`Run()`). On another thread (holding Sync): it goes to the scheduler's inbox.
    static method Ready(task: System.Threading.Tasks.Task) -> void
    // A Task.Run body starts, and has finished.
    static method Started() -> void
    static method Finished() -> void
    // Waits (another thread than the scheduler's) until `task` has finished.
    static method BlockUntil(task: System.Threading.Tasks.Task) -> void
    // Done in its turn (after what is ready now).
    static method Soon(task: System.Threading.Tasks.Task) -> void
    // Done after `milliseconds`.
    static method After(task: System.Threading.Tasks.Task, milliseconds: i32) -> void
    // Runs ready tasks and timers until `task` has finished (or nothing is left that could finish it).
    static method RunUntil(task: System.Threading.Tasks.Task) -> void
    // The timer that is due first.
    static method Soonest() -> i32
    // Completes the timers whose time has come (the first due first): whether there was one.
    static method Due(now: i64) -> bool
    // Completes the timers that are due; when none is, sleeps until the first one. Once threads complete tasks, the
    // sleep is on Changed (a task completed on another thread wakes it): the timer only bounds it.
    static method Timers() -> void
    static property Threaded: bool
    static property Sync: System.Threading.Mutex
    static property Changed: System.Threading.Condition
    // Whether a thread sleeps on Changed (read holding Sync).
    static property Sleeping: bool
}
Esc