Skip to content

Commit

Permalink
Fix local_cell method to actually create a local cell
Browse files Browse the repository at this point in the history
  • Loading branch information
bgw committed Jul 24, 2024
1 parent b635026 commit eeeda38
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion crates/turbo-tasks-macros/src/value_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream {
/// to be converted into normal cells.
#cell_prefix fn local_cell(self) -> turbo_tasks::Vc<Self> {
let content = self;
turbo_tasks::Vc::cell_private(#cell_access_content)
turbo_tasks::Vc::local_cell_private(#cell_access_content)
}
};

Expand Down
29 changes: 18 additions & 11 deletions crates/turbo-tasks/src/vc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,23 @@ where
pub fn cell_private(inner: <T::Read as VcRead<T>>::Target) -> Self {
<T::CellMode as VcCellMode<T>>::cell(inner)
}

// called by the `.local_cell()` method generated by the `#[turbo_tasks::value]`
// macro
#[doc(hidden)]
pub fn local_cell_private(inner: <T::Read as VcRead<T>>::Target) -> Self {
// `T::CellMode` isn't applicable here, we always create new local cells. Local
// cells aren't stored across executions, so there can be no concept of
// "updating" the cell across multiple executions.
let (execution_id, local_cell_id) = create_local_cell(SharedReference::new(
Some(T::get_value_type_id()),
triomphe::Arc::new(T::Read::target_to_repr(inner)),
));
Vc {
node: RawVc::LocalCell(execution_id, local_cell_id),
_t: PhantomData,
}
}
}

impl<T, Inner, Repr> Vc<T>
Expand All @@ -287,17 +304,7 @@ where
}

pub fn local_cell(inner: Inner) -> Self {
// `T::CellMode` isn't applicable here, we always create new local cells. Local
// cells aren't stored across executions, so there can be no concept of
// "updating" the cell across multiple executions.
let (execution_id, local_cell_id) = create_local_cell(SharedReference::new(
Some(T::get_value_type_id()),
triomphe::Arc::new(T::Read::target_to_repr(inner)),
));
Vc {
node: RawVc::LocalCell(execution_id, local_cell_id),
_t: PhantomData,
}
Self::local_cell_private(inner)
}
}

Expand Down

0 comments on commit eeeda38

Please sign in to comment.