Struct TurboTasks

Source
pub struct TurboTasks<B: Backend + 'static> { /* private fields */ }

Implementations§

Source§

impl<B: Backend + 'static> TurboTasks<B>

Source

pub fn new(backend: B) -> Arc<Self>

Source

pub fn pin(&self) -> Arc<Self>

Source

pub fn spawn_root_task<T, F, Fut>(&self, functor: F) -> TaskId
where T: ?Sized, F: Fn() -> Fut + Send + Sync + Clone + 'static, Fut: Future<Output = Result<Vc<T>>> + Send,

Creates a new root task

Source

pub fn dispose_root_task(&self, task_id: TaskId)

Source

pub fn spawn_once_task<T, Fut>(&self, future: Fut) -> TaskId
where T: ?Sized, Fut: Future<Output = Result<Vc<T>>> + Send + 'static,

Creates a new root task, that is only executed once. Dependencies will not invalidate the task.

Source

pub async fn run_once<T: TraceRawVcs + Send + 'static>( &self, future: impl Future<Output = Result<T>> + Send + 'static, ) -> Result<T>

Source

pub fn dynamic_call( &self, fn_type: FunctionId, this: Option<RawVc>, arg: Box<dyn MagicAny>, persistence: TaskPersistence, ) -> RawVc

Source

pub fn trait_call( &self, trait_type: TraitTypeId, trait_fn_name: Cow<'static, str>, this: RawVc, arg: Box<dyn MagicAny>, persistence: TaskPersistence, ) -> RawVc

Source

pub async fn wait_foreground_done(&self)

Source

pub fn get_in_progress_count(&self) -> usize

Source

pub async fn wait_task_completion( &self, id: TaskId, consistency: ReadConsistency, ) -> Result<()>

Waits for the given task to finish executing. This works by performing an untracked read, and discarding the value of the task output.

ReadConsistency::Eventual means that this will return after the task executes, but before all dependencies have completely settled.

ReadConsistency::Strong means that this will also wait for the task and all dependencies to fully settle before returning.

As this function is typically called in top-level code that waits for results to be ready for the user to access, most callers should use ReadConsistency::Strong.

Source

pub async fn get_or_wait_update_info( &self, aggregation: Duration, ) -> (Duration, usize)

👎Deprecated: Use get_or_wait_aggregated_update_info instead
Source

pub async fn update_info( &self, aggregation: Duration, timeout: Duration, ) -> Option<(Duration, usize)>

👎Deprecated: Use aggregated_update_info instead
Source

pub async fn get_or_wait_aggregated_update_info( &self, aggregation: Duration, ) -> UpdateInfo

Returns UpdateInfo with all updates aggregated over a given duration (aggregation). Will wait until an update happens.

Source

pub async fn aggregated_update_info( &self, aggregation: Duration, timeout: Duration, ) -> Option<UpdateInfo>

Returns UpdateInfo with all updates aggregated over a given duration (aggregation). Will only return None when the timeout is reached while waiting for the first update.

Source

pub async fn wait_background_done(&self)

Source

pub async fn stop_and_wait(&self)

Source

pub fn backend(&self) -> &B

Trait Implementations§

Source§

impl<B: Backend + 'static> TurboTasksApi for TurboTasks<B>

Source§

fn detached_for_testing( &self, fut: Pin<Box<dyn Future<Output = Result<()>> + Send + 'static>>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'static>>

Creates a future that inherits the current task id and task state. The current global task will wait for this future to be dropped before exiting.

Source§

fn pin(&self) -> Arc<dyn TurboTasksApi>

Source§

fn invalidate(&self, task: TaskId)

Source§

fn invalidate_with_reason( &self, task: TaskId, reason: StaticOrArc<dyn InvalidationReason>, )

Source§

fn invalidate_serialization(&self, task: TaskId)

Source§

fn notify_scheduled_tasks(&self)

Eagerly notifies all tasks that were scheduled for notifications via schedule_notify_tasks_set()
Source§

fn try_read_task_output( &self, task: TaskId, consistency: ReadConsistency, ) -> Result<Result<RawVc, EventListener>>

Source§

fn try_read_task_output_untracked( &self, task: TaskId, consistency: ReadConsistency, ) -> 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, options: ReadCellOptions, ) -> Result<Result<TypedCellContent, EventListener>>

Source§

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

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

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

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

fn try_read_local_output( &self, execution_id: ExecutionId, local_task_id: LocalTaskId, ) -> Result<Result<RawVc, EventListener>>

Reads a RawVc::LocalOutput. If the task has completed, returns the RawVc the local task points to. Read more
Source§

fn read_task_collectibles( &self, task: TaskId, trait_id: TraitTypeId, ) -> TaskCollectiblesMap

Source§

fn emit_collectible(&self, trait_type: TraitTypeId, collectible: RawVc)

Source§

fn unemit_collectible( &self, trait_type: TraitTypeId, collectible: RawVc, count: u32, )

Source§

fn unemit_collectibles( &self, trait_type: TraitTypeId, collectibles: &TaskCollectiblesMap, )

Source§

fn read_own_task_cell( &self, task: TaskId, index: CellId, options: ReadCellOptions, ) -> Result<TypedCellContent>

Source§

fn update_own_task_cell( &self, task: TaskId, index: CellId, content: CellContent, )

Source§

fn connect_task(&self, task: TaskId)

Source§

fn mark_own_task_as_finished(&self, task: TaskId)

Source§

fn set_own_task_aggregation_number(&self, task: TaskId, aggregation_number: u32)

Source§

fn mark_own_task_as_session_dependent(&self, task: TaskId)

Source§

fn task_statistics(&self) -> &TaskStatisticsApi

Source§

fn stop_and_wait(&self) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>

Source§

fn subscribe_to_compilation_events( &self, event_types: Option<Vec<String>>, ) -> Receiver<Arc<dyn CompilationEvent>>

Source§

fn send_compilation_event(&self, event: Arc<dyn CompilationEvent>)

Source§

impl<B: Backend + 'static> TurboTasksBackendApi<B> for TurboTasks<B>

Source§

fn schedule_notify_tasks(&self, tasks: &[TaskId])

Enqueues tasks for notification of changed dependencies. This will eventually call dependent_cell_updated() on all tasks.

Source§

fn schedule_notify_tasks_set(&self, tasks: &TaskIdSet)

Enqueues tasks for notification of changed dependencies. This will eventually call dependent_cell_updated() on all tasks.

Source§

fn pin(&self) -> Arc<dyn TurboTasksBackendApi<B>>

Source§

fn backend(&self) -> &B

Returns a reference to the backend.
Source§

fn schedule_backend_background_job(&self, id: BackendJobId)

Source§

fn schedule_backend_foreground_job(&self, id: BackendJobId)

Source§

fn try_foreground_done(&self) -> Result<(), EventListener>

Source§

fn wait_foreground_done_excluding_own<'a>( &'a self, ) -> Option<Pin<Box<dyn Future<Output = ()> + Send + 'a>>>

Source§

fn schedule(&self, task: TaskId)

Source§

fn program_duration_until(&self, instant: Instant) -> Duration

Returns the duration from the start of the program to the given instant.
Source§

fn get_fresh_persistent_task_id(&self) -> Unused<TaskId>

Source§

fn get_fresh_transient_task_id(&self) -> Unused<TaskId>

Source§

unsafe fn reuse_persistent_task_id(&self, id: Unused<TaskId>)

Safety Read more
Source§

unsafe fn reuse_transient_task_id(&self, id: Unused<TaskId>)

Safety Read more
Source§

fn read_task_state_dyn(&self, func: &mut dyn FnMut(&B::TaskState))

An untyped object-safe version of TurboTasksBackendApiExt::read_task_state. Callers should prefer the extension trait’s version of this method.
Source§

fn write_task_state_dyn(&self, func: &mut dyn FnMut(&mut B::TaskState))

An untyped object-safe version of TurboTasksBackendApiExt::write_task_state. Callers should prefer the extension trait’s version of this method.
Source§

fn is_idle(&self) -> bool

Returns true if the system is idle.
Source§

impl<B: Backend + 'static> TurboTasksCallApi for TurboTasks<B>

Source§

fn dynamic_call( &self, func: FunctionId, this: Option<RawVc>, arg: Box<dyn MagicAny>, persistence: TaskPersistence, ) -> RawVc

Calls a native function with arguments. Resolves arguments when needed with a wrapper task.
Source§

fn native_call( &self, func: FunctionId, this: Option<RawVc>, arg: Box<dyn MagicAny>, persistence: TaskPersistence, ) -> RawVc

Call a native function with arguments. All inputs must be resolved.
Source§

fn trait_call( &self, trait_type: TraitTypeId, trait_fn_name: Cow<'static, str>, this: RawVc, arg: Box<dyn MagicAny>, persistence: TaskPersistence, ) -> RawVc

Calls a trait method with arguments. First input is the self object. Uses a wrapper task to resolve
Source§

fn run_once( &self, future: Pin<Box<dyn Future<Output = Result<()>> + Send + 'static>>, ) -> TaskId

Source§

fn run_once_with_reason( &self, reason: StaticOrArc<dyn InvalidationReason>, future: Pin<Box<dyn Future<Output = Result<()>> + Send + 'static>>, ) -> TaskId

Source§

fn run_once_process( &self, future: Pin<Box<dyn Future<Output = Result<()>> + Send + 'static>>, ) -> TaskId

Auto Trait Implementations§

§

impl<B> !Freeze for TurboTasks<B>

§

impl<B> !RefUnwindSafe for TurboTasks<B>

§

impl<B> Send for TurboTasks<B>

§

impl<B> Sync for TurboTasks<B>

§

impl<B> Unpin for TurboTasks<B>
where B: Unpin,

§

impl<B> !UnwindSafe for TurboTasks<B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for T
where T: Any,

§

fn get_type_id(&self) -> TypeId

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<TT, B> TurboTasksBackendApiExt<B> for TT
where TT: TurboTasksBackendApi<B> + ?Sized, B: Backend + 'static,

Source§

fn read_task_state<T>(&self, func: impl FnOnce(&B::TaskState) -> T) -> T

Allows modification of the Backend::TaskState. Read more
Source§

fn write_task_state<T>(&self, func: impl FnOnce(&mut B::TaskState) -> T) -> T

Allows modification of the Backend::TaskState. Read more
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more