pub struct OperationVc<T>where
T: ?Sized,{ /* private fields */ }Expand description
A “subtype” (can be converted via .connect()) of Vc that
represents a specific call (with arguments) to a task.
Unlike Vc, OperationVc:
-
Does not potentially refer to task-local information, meaning that it implements
NonLocalValue, and can be used in any#[turbo_tasks::value]. -
Has only one potential internal representation, meaning that it has a saner equality definition.
-
Can be reconnected to the strongly-consistent compilation graph after being placed inside of a
State. -
Makes sense with collectibles, as it represents a function call, and only function calls can have issues or side-effects.
§Equality & Hashing
Equality between two OperationVcs means that both have an identical in-memory representation
and point to the same task function call. The implementation of Hash has similar behavior.
If connected and then .awaited at the same time, both would likely resolve to the same
ReadRef, though it is possible that they may not if the task or cell is invalidated between
.awaits.
Because equality is a synchronous operation that cannot read the cell contents, even if the
OperationVcs are not equal, it is possible that if .awaited, both OperationVcs could point
to the same or equal values.
Implementations§
Source§impl<T: ?Sized> OperationVc<T>
impl<T: ?Sized> OperationVc<T>
Sourcepub fn connect(self) -> Vc<T>
pub fn connect(self) -> Vc<T>
Marks this operation’s underlying function call as a child of the current task, and returns
a Vc that can be resolved or read with .await?.
By marking this function call as a child of the current task, turbo-tasks will re-run tasks
as-needed to achieve strong consistency at the root of the function call tree. This explicit
operation is needed as OperationVc types can be stored outside of the call graph as part
of States.
Sourcepub fn upcast<K>(vc: Self) -> OperationVc<K>
pub fn upcast<K>(vc: Self) -> OperationVc<K>
Upcasts the given OperationVc<T> to a OperationVc<Box<dyn K>>.
This is also available as an Into/From conversion.
Sourcepub async fn resolve_strongly_consistent(self) -> Result<ResolvedVc<T>>
pub async fn resolve_strongly_consistent(self) -> Result<ResolvedVc<T>>
Connects the OperationVc and resolves the reference
until it points to a cell directly in a strongly
consistent way.
Resolving will wait for task execution to be finished, so that the returned ResolvedVc
points to a cell that stores a value.
Resolving is necessary to compare identities of Vcs.
This is async and will rethrow any fatal error that happened during task execution.
Sourcepub fn read_strongly_consistent(self) -> ReadVcFuture<T> ⓘwhere
T: VcValueType,
pub fn read_strongly_consistent(self) -> ReadVcFuture<T> ⓘwhere
T: VcValueType,
Connects the OperationVc and returns a strongly
consistent read of the value.
This ensures that all internal tasks are finished before the read is returned.
Trait Implementations§
Source§impl<T> Clone for OperationVc<T>where
T: ?Sized,
impl<T> Clone for OperationVc<T>where
T: ?Sized,
Source§impl<T> CollectiblesSource for OperationVc<T>where
T: ?Sized,
impl<T> CollectiblesSource for OperationVc<T>where
T: ?Sized,
fn drop_collectibles<Vt: VcValueTrait>(self)
fn take_collectibles<Vt: VcValueTrait>(self) -> AutoSet<ResolvedVc<Vt>>
fn peek_collectibles<Vt: VcValueTrait>(self) -> AutoSet<ResolvedVc<Vt>>
Source§impl<T> Debug for OperationVc<T>where
T: ?Sized,
impl<T> Debug for OperationVc<T>where
T: ?Sized,
Source§impl<'de, T> Deserialize<'de> for OperationVc<T>where
T: ?Sized,
impl<'de, T> Deserialize<'de> for OperationVc<T>where
T: ?Sized,
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl<T> Hash for OperationVc<T>where
T: ?Sized,
impl<T> Hash for OperationVc<T>where
T: ?Sized,
Source§impl<T> PartialEq for OperationVc<T>where
T: ?Sized,
impl<T> PartialEq for OperationVc<T>where
T: ?Sized,
Source§impl<T> Serialize for OperationVc<T>where
T: ?Sized,
impl<T> Serialize for OperationVc<T>where
T: ?Sized,
Source§impl<T> TaskInput for OperationVc<T>
impl<T> TaskInput for OperationVc<T>
fn is_transient(&self) -> bool
fn resolve_input(&self) -> impl Future<Output = Result<Self>> + Send + '_
fn is_resolved(&self) -> bool
Source§impl<T> TraceRawVcs for OperationVc<T>where
T: ?Sized,
impl<T> TraceRawVcs for OperationVc<T>where
T: ?Sized,
fn trace_raw_vcs(&self, trace_context: &mut TraceRawVcsContext)
fn get_raw_vcs(&self) -> Vec<RawVc>
impl<T> Copy for OperationVc<T>where
T: ?Sized,
impl<T> Eq for OperationVc<T>where
T: ?Sized,
impl<T: NonLocalValue + ?Sized> NonLocalValue for OperationVc<T>
impl<T: ?Sized + Send> OperationValue for OperationVc<T>
Auto Trait Implementations§
impl<T> Freeze for OperationVc<T>where
T: ?Sized,
impl<T> RefUnwindSafe for OperationVc<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for OperationVc<T>
impl<T> Sync for OperationVc<T>
impl<T> Unpin for OperationVc<T>where
T: ?Sized,
impl<T> UnwindSafe for OperationVc<T>where
T: UnwindSafe + ?Sized,
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> DynPartialEq for T
impl<T> DynPartialEq for T
fn dyn_partial_eq(&self, other: &(dyn Any + 'static)) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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