Thread
class Thread
A class representing an individual thread.
Thread is a wrapper for a generator that can be executed concurrently.
Aside from the main thread, all threads need to have a parent. If a parent finishes execution, all of its child threads are terminated.
Constructors
constructor
public new Threadrunner: ThreadGeneratortask?: Thread: Thread
Parameters
runner: ThreadGeneratortask?: Thread
The generator wrapped by this thread.
Properties
children
parent
runner
readonly public runner: ThreadGeneratortask?: Thread
The generator wrapped by this thread.
time
readonly public time: SimpleSignalnumbervoid = ...
The current time of this thread.
Used by waitFor
and other time-based functions to properly
support durations shorter than one frame.
value
public value: unknown
The next value to be passed to the wrapped generator.
Accessors
canceled
public get canceled(): boolean
Check if this thread or any of its ancestors has been canceled.
fixed
public get fixed(): number
The fixed time of this thread.
Fixed time is a multiple of the frame duration. It can be used to account
for the difference between this thread's time
and the time of the
current animation frame.
onDeferred
public get onDeferred(): SubscribablevoidEventHandlervoid
paused
public get paused(): boolean
root
public get root(): Thread
Methods
add
Parameters
cancel
public cancel(): void
drain
public draincallback: task: ThreadGenerator => void: void
Parameters
callback: task: ThreadGenerator => void
next
public next(): IteratorYieldResultvoidPromiseanyThreadGeneratorPromisableanyIteratorReturnResultvoiddone: boolean = falsevalue: null = null
Progress the wrapped generator once.
pause
public pausevalue: boolean: void
Parameters
value: boolean
runDeferred
public runDeferred(): void
spawn
public spawnchild: ThreadGenerator() => ThreadGenerator: ThreadGenerator
Parameters
update
public updatedt: number: void
Prepare the thread for the next update cycle.
Parameters
dt: number
The delta time of the next cycle.