Crate turbo_tasks

Source
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.
  • Vcs (“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 Vcs 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§

pub use task::SharedReference;
pub use task::TypedSharedReference;

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-printing Vc types.

Structs§

ApplyEffectsContext
CellId
Completion
Just an empty type, but it’s never equal to itself.
Completions
This is a transparent value type wrapping Vec<ResolvedVc<Completion>>.
CurrentCellRef
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.
ExecutionId
An identifier for a specific task execution. Used to assert that local Vcs don’t leak. This value may overflow and re-use old values.
FunctionId
InvalidationReasonSet
A set of InvalidationReasons. They are automatically deduplicated and merged by kind during insertion. It implements Display to get a readable representation.
Invalidator
LocalTaskId
Represents the nth local function call inside a task.
OperationVc
A “subtype” (can be converted via .connect()) of Vc that represents a specific call (with arguments) to a task.
ReadCellOptions
ReadRawVcFuture
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.
ReadVcFuture
ResolvedVc
A “subtype” (via Deref) of Vc that represents a specific Vc::cell/.cell() or ResolvedVc::cell/.resolved_cell() constructor call within a task.
SerializationInvalidator
SessionId
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
TraitMethod
TraitRef
Similar to a ReadRef<T>, but contains a value trait object instead.
TraitType
TraitTypeId
TransientInstance
Pass a reference to an instance to a turbo-tasks function.
TransientState
TransientValue
Pass a value by value (Value<Xxx>) instead of by reference (Vc<Xxx>).
TurboTasks
TurboTasksPanic
Unused
A wrapper around a value that is unused.
UpdateInfo
Value
Pass a value by value (Value<Xxx>) instead of by reference (Vc<Xxx>).
ValueType
A definition of a type of data.
ValueTypeId
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.
VcCellNewMode
Mode that always updates the cell’s content.
VcCellSharedMode
Mode that compares the cell’s content with the new value and only updates if the new value is different.
VcDefaultRead
Representation for standard #[turbo_tasks::value], where a read return a reference to the value type[]
VcTransparentRead
Representation for #[turbo_tasks::value(transparent)] types, where reads return a reference to the target type.
VcValueTraitCast
Casts an arbitrary cell content into a TraitRef<T>.
VcValueTypeCast
Casts an arbitrary cell content into a ReadRef<T>.

Enums§

OutputContent
A helper type representing the output of a resolved task.
RawVc
A type-erased representation of Vc.
ReadConsistency
ResolveTypeError
TaskPersistence

Constants§

TRANSIENT_TASK_BIT

Traits§

CollectiblesSource
Implemented on OperationVc and RawVc.
Dynamic
Marker trait that indicates that a Vc<Self> can accept all methods declared on a Vc<T>.
DynamicEqHash
IntoTraitRef
A trait that allows a value trait vc to be converted into a trait reference.
InvalidationReason
A user-facing reason why a task was invalidated. This should only be used for invalidation that were triggered by the user.
InvalidationReasonKind
Invalidation reason kind. This is used to merge multiple reasons of the same kind into a combined description.
JoinIterExt
KeyValuePair
MagicAny
NonLocalValue
Marker trait indicating that a type does not contain any instances of Vc or references to Vc. It may contain ResolvedVc or OperationVc.
OperationValue
Indicates that a type does not contain any instances of Vc or ResolvedVc. It may contain OperationVc.
OptionVcExt
ShrinkToFit
Recursively calls shrink_to_fit on all elements of the container.
TaskInput
Trait to implement in order for a type to be accepted as a #[turbo_tasks::function] argument.
TryFlatJoinIterExt
TryJoinIterExt
TurboTasksApi
A type-erased subset of TurboTasks stored inside a thread local when we’re in a turbo task context. Returned by the turbo_tasks helper function.
TurboTasksBackendApi
A subset of the TurboTasks API that’s exposed to Backend implementations.
TurboTasksBackendApiExt
An extension trait for methods of TurboTasksBackendApi that are not object-safe. This is automatically implemented for all TurboTasksBackendApis using a blanket impl.
TurboTasksCallApi
Common base trait for TurboTasksApi and TurboTasksBackendApi. Provides APIs for creating tasks from function calls.
TypedForInput
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 a Vc<T>.
ValueDefault
Vc<T> analog to the Default trait.
ValueToString
VcCast
Trait defined to share behavior between values and traits within ReadRawVcFuture. See VcValueTypeCast and VcValueTraitCast.
VcRead
Trait that controls crate::Vc’s read representation.
VcValueTrait
A trait implemented on all values trait object references that can be put into a Value Cell (Vc<Box<dyn Trait>>).
VcValueType
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 the turbo_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§

FxDashMap
FxIndexMap
FxIndexSet
Result
Result<T, Error>
SliceMap
TaskIdSet

Attribute Macros§

function
value
Implements VcValueType for the given struct or enum. These value types can be used inside of a “value cell” as Vc<...>.
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§

KeyValuePair
Derives the KeyValuePair trait for a enum. Each variant need to have a value field which becomes part of the value enum and all remaining fields become part of the key.
NonLocalValue
Implements NonLocalValue for a struct or enum by adding static (compile-time) assertions that every field implements NonLocalValue.
OperationValue
ShrinkToFit
TaskInput