Expand description
A task scheduling and caching system that is focused on incremental execution.
It defines 4 primitives:
- Functions: Units of execution, invalidation, and reexecution.
- Values: Data created, stored, and returned by functions.
- Traits: Traits that define a set of functions on values.
- Collectibles: Values emitted in functions that bubble up the call graph and can be collected in parent functions.
It also defines some derived elements from that:
- Tasks: An instance of a function together with its arguments.
- Cells: The locations associated with tasks where values are stored. The contents of a cell can change after the reexecution of a function.
Vc
s (“Value Cells”): A reference to a cell or a return value of a function.
A Vc
can be read to get a read-only reference to the stored data, representing a
snapshot of that cell at that point in time.
On execution of functions, turbo-tasks
will track which Vc
s are read. Once any of these
change, turbo-tasks
will invalidate the task created from the function’s execution and it will
eventually be scheduled and reexecuted.
Collectibles go through a similar process.
Re-exports§
Modules§
- backend
- debug
- duration_
span - event
- graph
- message_
queue - persisted_
graph - primitives
- registry
- small_
duration - task
- task_
statistics - test_
helpers - trace
- util
Macros§
- duration_
span - Creates a event-based span that traces a certain duration (lifetime of the guard). It’s not a real span, which means it can be used across threads.
- fxindexmap
- fxindexset
- stringify_
path - vdbg
- This macro supports the same syntax as
dbg!
, but also supports pretty-printingVc
types.
Structs§
- Apply
Effects Context - CellId
- Completion
- Just an empty type, but it’s never equal to itself.
- Completions
- This is a transparent value type wrapping
Vec<ResolvedVc<Completion>>
. - Current
Cell Ref - A reference to a task’s cell with methods that allow updating the contents of the cell.
- Effects
- Captured effects from an operation. This struct can be used to return Effects from a turbo-tasks function and apply them later.
- Error
- The
Error
type, a wrapper around a dynamic error type. - Execution
Id - An identifier for a specific task execution. Used to assert that local
Vc
s don’t leak. This value may overflow and re-use old values. - Function
Id - Invalidation
Reason Set - A set of InvalidationReasons. They are automatically deduplicated and merged by kind during insertion. It implements Display to get a readable representation.
- Invalidator
- Local
Task Id - Represents the nth
local
function call inside a task. - Operation
Vc - A “subtype” (can be converted via
.connect()
) ofVc
that represents a specific call (with arguments) to a task. - Read
Cell Options - Read
RawVc Future - ReadRef
- The read value of a value cell. The read value is immutable, while the cell itself might change over time. It’s basically a snapshot of a value at a certain point in time.
- Read
VcFuture - Resolved
Vc - A “subtype” (via
Deref
) ofVc
that represents a specificVc::cell
/.cell()
orResolvedVc::cell
/.resolved_cell()
constructor call within a task. - Serialization
Invalidator - Session
Id - State
- This API violates core assumption of turbo-tasks, is believed to be unsound, and there’s no plan fix it. You should prefer to use collectibles instead of state where at all possible. This API may be removed in the future.
- TaskId
- Trait
Method - Trait
Ref - Similar to a
ReadRef<T>
, but contains a value trait object instead. - Trait
Type - Trait
Type Id - Transient
Instance - Pass a reference to an instance to a turbo-tasks function.
- Transient
State - Transient
Value - Pass a value by value (
Value<Xxx>
) instead of by reference (Vc<Xxx>
). - Turbo
Tasks - Turbo
Tasks Panic - Unused
- A wrapper around a value that is unused.
- Update
Info - Value
- Pass a value by value (
Value<Xxx>
) instead of by reference (Vc<Xxx>
). - Value
Type - A definition of a type of data.
- Value
Type Id - Vc
- A “Value Cell” (
Vc
for short) is a reference to a memoized computation result stored on the heap or in persistent cache, depending on the Turbo Engine backend implementation. - VcCell
NewMode - Mode that always updates the cell’s content.
- VcCell
Shared Mode - Mode that compares the cell’s content with the new value and only updates if the new value is different.
- VcDefault
Read - Representation for standard
#[turbo_tasks::value]
, where a read return a reference to the value type[] - VcTransparent
Read - Representation for
#[turbo_tasks::value(transparent)]
types, where reads return a reference to the target type. - VcValue
Trait Cast - Casts an arbitrary cell content into a
TraitRef<T>
. - VcValue
Type Cast - Casts an arbitrary cell content into a
ReadRef<T>
.
Enums§
- Output
Content - A helper type representing the output of a resolved task.
- RawVc
- A type-erased representation of
Vc
. - Read
Consistency - Resolve
Type Error - Task
Persistence
Constants§
Traits§
- Collectibles
Source - Implemented on
OperationVc
andRawVc
. - Dynamic
- Marker trait that indicates that a
Vc<Self>
can accept all methods declared on aVc<T>
. - Dynamic
EqHash - Into
Trait Ref - A trait that allows a value trait vc to be converted into a trait reference.
- Invalidation
Reason - A user-facing reason why a task was invalidated. This should only be used for invalidation that were triggered by the user.
- Invalidation
Reason Kind - Invalidation reason kind. This is used to merge multiple reasons of the same kind into a combined description.
- Join
Iter Ext - KeyValue
Pair - Magic
Any - NonLocal
Value - Marker trait indicating that a type does not contain any instances of
Vc
or references toVc
. It may containResolvedVc
orOperationVc
. - Operation
Value - Indicates that a type does not contain any instances of
Vc
orResolvedVc
. It may containOperationVc
. - Option
VcExt - Shrink
ToFit - Recursively calls
shrink_to_fit
on all elements of the container. - Task
Input - Trait to implement in order for a type to be accepted as a
#[turbo_tasks::function]
argument. - TryFlat
Join Iter Ext - TryJoin
Iter Ext - Turbo
Tasks Api - A type-erased subset of
TurboTasks
stored inside a thread local when we’re in a turbo task context. Returned by theturbo_tasks
helper function. - Turbo
Tasks Backend Api - A subset of the
TurboTasks
API that’s exposed toBackend
implementations. - Turbo
Tasks Backend ApiExt - An extension trait for methods of
TurboTasksBackendApi
that are not object-safe. This is automatically implemented for allTurboTasksBackendApi
s using a blanket impl. - Turbo
Tasks Call Api - Common base trait for
TurboTasksApi
andTurboTasksBackendApi
. Provides APIs for creating tasks from function calls. - Typed
ForInput - Marker trait that a turbo_tasks::value is prepared for serialization as
Value<...>
input. - Upcast
- Marker trait that indicates that a
Vc<Self>
can be upcasted to aVc<T>
. - Value
Default Vc<T>
analog to theDefault
trait.- Value
ToString - VcCast
- Trait defined to share behavior between values and traits within
ReadRawVcFuture
. SeeVcValueTypeCast
andVcValueTraitCast
. - VcRead
- Trait that controls
crate::Vc
’s read representation. - VcValue
Trait - A trait implemented on all values trait object references that can be put
into a Value Cell (
Vc<Box<dyn Trait>>
). - VcValue
Type - A trait implemented on all values types that can be put into a Value Cell
(
Vc<T>
).
Functions§
- apply_
effects - Applies all effects that have been emitted by an operations.
- dynamic_
call - Calls
TurboTasks::dynamic_call
for the current turbo tasks instance. - effect
- Schedules an effect to be applied. The passed future is executed once
apply_effects
is called. - emit
- get_
effects - Capture effects from an turbo-tasks operation. Since this captures collectibles it might invalidate the current task when effects are changing or even temporary change.
- get_
invalidator - Get an
Invalidator
that can be used to invalidate the current task based on external events. - handle_
panic - mark_
finished - Marks the current task as finished. This excludes it from waiting for strongly consistency.
- mark_
root - Marks the current task as finished. This excludes it from waiting for strongly consistency.
- mark_
session_ dependent - Marks the current task as dirty when restored from persistent cache.
- mark_
stateful - Marks the current task as stateful. This prevents the tasks from being dropped without persisting the state.
- prevent_
gc - register
- run_
once - run_
once_ with_ reason - scope
- A wrapper around [
rayon::in_place_scope
] that preserves theturbo_tasks_scope
. - spawn_
blocking - spawn_
thread - trait_
call - Calls
TurboTasks::trait_call
for the current turbo tasks instance. - turbo_
tasks - turbo_
tasks_ scope
Type Aliases§
- FxDash
Map - FxIndex
Map - FxIndex
Set - Result
Result<T, Error>
- Slice
Map - Task
IdSet
Attribute Macros§
- function
- value
- Implements
VcValueType
for the givenstruct
orenum
. These value types can be used inside of a “value cell” asVc<...>
. - value_
impl - value_
trait - Allows this trait to be used as part of a trait object inside of a value
cell, in the form of
Vc<dyn MyTrait>
.
Derive Macros§
- KeyValue
Pair - Derives the
KeyValuePair
trait for a enum. Each variant need to have avalue
field which becomes part of the value enum and all remaining fields become part of the key. - NonLocal
Value - Implements
NonLocalValue
for a struct or enum by adding static (compile-time) assertions that every field implementsNonLocalValue
. - Operation
Value - Shrink
ToFit - Task
Input