@revideo/core / threading / Thread
Class: Thread
Defined in: threading/Thread.ts:66
A class representing an individual thread.
Remarks
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
new Thread(
runner):Thread
Defined in: threading/Thread.ts:111
Parameters
runner
ThreadGenerator & { task?: Thread; }
The generator wrapped by this thread.
Returns
Thread
Properties
children
children:
Thread[] =[]
Defined in: threading/Thread.ts:67
parent
parent:
Thread|null=null
Defined in: threading/Thread.ts:105
runner
readonlyrunner:ThreadGenerator& {task?:Thread; }
Defined in: threading/Thread.ts:115
The generator wrapped by this thread.
Type Declaration
task?
optionaltask?:Thread
time
readonlytime:SimpleSignal<number,void>
Defined in: threading/Thread.ts:80
The current time of this thread.
Remarks
Used by flow.waitFor and other time-based functions to properly support durations shorter than one frame.
value
value:
unknown
Defined in: threading/Thread.ts:71
The next value to be passed to the wrapped generator.
Accessors
canceled
Get Signature
get canceled():
boolean
Defined in: threading/Thread.ts:97
Check if this thread or any of its ancestors has been canceled.
Returns
boolean
fixed
Get Signature
get fixed():
number
Defined in: threading/Thread.ts:90
The fixed time of this thread.
Remarks
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.
Returns
number
paused
Get Signature
get paused():
boolean
Defined in: threading/Thread.ts:101
Returns
boolean
Methods
add()
add(
child):void
Defined in: threading/Thread.ts:170
Parameters
child
Thread
Returns
void
cancel()
cancel():
void
Defined in: threading/Thread.ts:185
Returns
void
drain()
drain(
callback):void
Defined in: threading/Thread.ts:180
Parameters
callback
(task) => void
Returns
void
next()
next():
IteratorYieldResult<void|ThreadGenerator|Promise<any> |Promisable<any>> |IteratorReturnResult<void> | {done:boolean;value:null; }
Defined in: threading/Thread.ts:132
Progress the wrapped generator once.
Returns
IteratorYieldResult<void | ThreadGenerator | Promise<any> | Promisable<any>> | IteratorReturnResult<void> | { done: boolean; value: null; }
pause()
pause(
value):void
Defined in: threading/Thread.ts:192
Parameters
value
boolean
Returns
void
spawn()
spawn(
child):ThreadGenerator
Defined in: threading/Thread.ts:160
Parameters
child
ThreadGenerator | (() => ThreadGenerator)
Returns
update()
update(
dt):void
Defined in: threading/Thread.ts:152
Prepare the thread for the next update cycle.
Parameters
dt
number
The delta time of the next cycle.
Returns
void