Trait Backend

Source
pub trait Backend: Sync + Send {
    type TaskState: Send + Sync + 'static;

Show 35 methods // Required methods fn invalidate_task( &self, task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ); fn invalidate_tasks( &self, tasks: &[TaskId], turbo_tasks: &dyn TurboTasksBackendApi<Self>, ); fn invalidate_tasks_set( &self, tasks: &TaskIdSet, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ); fn get_task_description(&self, task: TaskId) -> String; fn new_task_state(&self, task: TaskId) -> Self::TaskState; fn try_start_task_execution<'a>( &'a self, task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> Option<TaskExecutionSpec<'a>>; fn task_execution_canceled( &self, task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ); fn task_execution_result( &self, task_id: TaskId, result: Result<RawVc, Arc<TurboTasksExecutionError>>, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ); fn task_execution_completed( &self, task: TaskId, duration: Duration, memory_usage: usize, cell_counters: &AutoMap<ValueTypeId, u32, BuildHasherDefault<FxHasher>, 8>, stateful: bool, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> bool; fn run_backend_job<'a>( &'a self, id: BackendJobId, turbo_tasks: &'a dyn TurboTasksBackendApi<Self>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>; fn try_read_task_output( &self, task: TaskId, reader: TaskId, consistency: ReadConsistency, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> Result<Result<RawVc, EventListener>>; fn try_read_task_output_untracked( &self, task: TaskId, consistency: ReadConsistency, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> Result<Result<RawVc, EventListener>>; fn try_read_task_cell( &self, task: TaskId, index: CellId, reader: TaskId, options: ReadCellOptions, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> Result<Result<TypedCellContent, EventListener>>; fn try_read_task_cell_untracked( &self, task: TaskId, index: CellId, options: ReadCellOptions, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> Result<Result<TypedCellContent, EventListener>>; fn read_task_collectibles( &self, task: TaskId, trait_id: TraitTypeId, reader: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> TaskCollectiblesMap; fn emit_collectible( &self, trait_type: TraitTypeId, collectible: RawVc, task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ); fn unemit_collectible( &self, trait_type: TraitTypeId, collectible: RawVc, count: u32, task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ); fn update_task_cell( &self, task: TaskId, index: CellId, content: CellContent, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ); fn get_or_create_persistent_task( &self, task_type: CachedTaskType, parent_task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> TaskId; fn get_or_create_transient_task( &self, task_type: CachedTaskType, parent_task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> TaskId; fn try_get_function_id(&self, task_id: TaskId) -> Option<FunctionId>; fn connect_task( &self, task: TaskId, parent_task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ); fn create_transient_task( &self, task_type: TransientTaskType, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> TaskId; fn dispose_root_task( &self, task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ); fn task_statistics(&self) -> &TaskStatisticsApi; // Provided methods fn startup(&self, turbo_tasks: &dyn TurboTasksBackendApi<Self>) { ... } fn stop(&self, turbo_tasks: &dyn TurboTasksBackendApi<Self>) { ... } fn stopping(&self, turbo_tasks: &dyn TurboTasksBackendApi<Self>) { ... } fn idle_start(&self, turbo_tasks: &dyn TurboTasksBackendApi<Self>) { ... } fn idle_end(&self, turbo_tasks: &dyn TurboTasksBackendApi<Self>) { ... } fn invalidate_serialization( &self, _task: TaskId, _turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) { ... } fn try_read_own_task_cell_untracked( &self, current_task: TaskId, index: CellId, options: ReadCellOptions, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> Result<TypedCellContent> { ... } fn mark_own_task_as_finished( &self, _task: TaskId, _turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) { ... } fn set_own_task_aggregation_number( &self, _task: TaskId, _aggregation_number: u32, _turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) { ... } fn mark_own_task_as_session_dependent( &self, _task: TaskId, _turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) { ... }
}

Required Associated Types§

Source

type TaskState: Send + Sync + 'static

Task-local state that stored inside of TurboTasksBackendApi. Constructed with Self::new_task_state.

This value that can later be written to or read from using crate::TurboTasksBackendApiExt::write_task_state or crate::TurboTasksBackendApiExt::read_task_state

This data may be shared across multiple threads (must be Sync) in order to support detached futures (crate::TurboTasksApi::detached_for_testing) and pseudo-tasks using local execution. A RwLock is used to provide concurrent access.

Required Methods§

Source

fn invalidate_task( &self, task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, )

Source

fn invalidate_tasks( &self, tasks: &[TaskId], turbo_tasks: &dyn TurboTasksBackendApi<Self>, )

Source

fn invalidate_tasks_set( &self, tasks: &TaskIdSet, turbo_tasks: &dyn TurboTasksBackendApi<Self>, )

Source

fn get_task_description(&self, task: TaskId) -> String

Source

fn new_task_state(&self, task: TaskId) -> Self::TaskState

Constructs a new task-local Self::TaskState for the given task_id.

If a task is re-executed (e.g. because it is invalidated), this function will be called again with the same TaskId.

This value can be written to or read from using crate::TurboTasksBackendApiExt::write_task_state and crate::TurboTasksBackendApiExt::read_task_state

Source

fn try_start_task_execution<'a>( &'a self, task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> Option<TaskExecutionSpec<'a>>

Source

fn task_execution_canceled( &self, task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, )

Source

fn task_execution_result( &self, task_id: TaskId, result: Result<RawVc, Arc<TurboTasksExecutionError>>, turbo_tasks: &dyn TurboTasksBackendApi<Self>, )

Source

fn task_execution_completed( &self, task: TaskId, duration: Duration, memory_usage: usize, cell_counters: &AutoMap<ValueTypeId, u32, BuildHasherDefault<FxHasher>, 8>, stateful: bool, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> bool

Source

fn run_backend_job<'a>( &'a self, id: BackendJobId, turbo_tasks: &'a dyn TurboTasksBackendApi<Self>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>

Source

fn try_read_task_output( &self, task: TaskId, reader: TaskId, consistency: ReadConsistency, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> Result<Result<RawVc, EventListener>>

Source

fn try_read_task_output_untracked( &self, task: TaskId, consistency: ReadConsistency, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> Result<Result<RawVc, EventListener>>

INVALIDATION: Be careful with this, it will not track dependencies, so using it could break cache invalidation.

Source

fn try_read_task_cell( &self, task: TaskId, index: CellId, reader: TaskId, options: ReadCellOptions, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> Result<Result<TypedCellContent, EventListener>>

Source

fn try_read_task_cell_untracked( &self, task: TaskId, index: CellId, options: ReadCellOptions, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> Result<Result<TypedCellContent, EventListener>>

INVALIDATION: Be careful with this, it will not track dependencies, so using it could break cache invalidation.

Source

fn read_task_collectibles( &self, task: TaskId, trait_id: TraitTypeId, reader: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> TaskCollectiblesMap

Source

fn emit_collectible( &self, trait_type: TraitTypeId, collectible: RawVc, task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, )

Source

fn unemit_collectible( &self, trait_type: TraitTypeId, collectible: RawVc, count: u32, task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, )

Source

fn update_task_cell( &self, task: TaskId, index: CellId, content: CellContent, turbo_tasks: &dyn TurboTasksBackendApi<Self>, )

Source

fn get_or_create_persistent_task( &self, task_type: CachedTaskType, parent_task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> TaskId

Source

fn get_or_create_transient_task( &self, task_type: CachedTaskType, parent_task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> TaskId

Source

fn try_get_function_id(&self, task_id: TaskId) -> Option<FunctionId>

For persistent tasks with associated [NativeFunction][crate::native_function::NativeFunction]s, return the FunctionId.

Source

fn connect_task( &self, task: TaskId, parent_task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, )

Source

fn create_transient_task( &self, task_type: TransientTaskType, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> TaskId

Source

fn dispose_root_task( &self, task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>, )

Source

fn task_statistics(&self) -> &TaskStatisticsApi

Provided Methods§

Source

fn startup(&self, turbo_tasks: &dyn TurboTasksBackendApi<Self>)

Source

fn stop(&self, turbo_tasks: &dyn TurboTasksBackendApi<Self>)

Source

fn stopping(&self, turbo_tasks: &dyn TurboTasksBackendApi<Self>)

Source

fn idle_start(&self, turbo_tasks: &dyn TurboTasksBackendApi<Self>)

Source

fn idle_end(&self, turbo_tasks: &dyn TurboTasksBackendApi<Self>)

Source

fn invalidate_serialization( &self, _task: TaskId, _turbo_tasks: &dyn TurboTasksBackendApi<Self>, )

Source

fn try_read_own_task_cell_untracked( &self, current_task: TaskId, index: CellId, options: ReadCellOptions, turbo_tasks: &dyn TurboTasksBackendApi<Self>, ) -> Result<TypedCellContent>

INVALIDATION: Be careful with this, it will not track dependencies, so using it could break cache invalidation.

Source

fn mark_own_task_as_finished( &self, _task: TaskId, _turbo_tasks: &dyn TurboTasksBackendApi<Self>, )

Source

fn set_own_task_aggregation_number( &self, _task: TaskId, _aggregation_number: u32, _turbo_tasks: &dyn TurboTasksBackendApi<Self>, )

Source

fn mark_own_task_as_session_dependent( &self, _task: TaskId, _turbo_tasks: &dyn TurboTasksBackendApi<Self>, )

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§