diff --git a/crates/turbo-tasks/src/keyed_cell.rs b/crates/turbo-tasks/src/keyed_cell.rs deleted file mode 100644 index ffacf6220fbb7..0000000000000 --- a/crates/turbo-tasks/src/keyed_cell.rs +++ /dev/null @@ -1,77 +0,0 @@ -use anyhow::Result; - -use crate::{ - self as turbo_tasks, macro_helpers::find_cell_by_type, manager::current_task, - ConcreteTaskInput, CurrentCellRef, RawVc, TaskId, TaskInput, ValueTypeId, Vc, VcValueType, -}; - -#[turbo_tasks::value] -struct KeyedCell { - cell: RawVc, - #[turbo_tasks(trace_ignore, debug_ignore)] - cell_ref: CurrentCellRef, -} - -#[turbo_tasks::value_impl] -impl KeyedCell { - #[turbo_tasks::function] - fn new_local(_task: TaskId, _key: ConcreteTaskInput, value_type_id: ValueTypeId) -> Vc { - let cell_ref = find_cell_by_type(value_type_id); - KeyedCell { - cell: cell_ref.into(), - cell_ref, - } - .cell() - } - - #[turbo_tasks::function] - fn new_global(_key: ConcreteTaskInput, value_type_id: ValueTypeId) -> Vc { - let cell_ref = find_cell_by_type(value_type_id); - KeyedCell { - cell: cell_ref.into(), - cell_ref, - } - .cell() - } -} - -/// Cells a value in a cell with a given key. A key MUST only be used once per -/// function. -/// -/// Usually calling [Vc::cell] will create cells for a give type based on the -/// call order of [Vc::cell]. But this can yield to over-invalidation when the -/// number of cells changes. e. g. not doing the first [Vc::cell] call will move -/// all remaining values into different cells, causing invalidation of all of -/// them. -/// -/// A keyed cell avoids this problem by not using call order, but a key instead. -/// -/// Internally it creates a new Task based on the key and cells the value into -/// that task. This is a implementation detail and might change in the future. -pub async fn keyed_cell( - key: K, - content: T, -) -> Result> { - let cell = KeyedCell::new_local( - current_task("keyed_cell"), - key.into_concrete(), - T::get_value_type_id(), - ) - .await?; - cell.cell_ref.compare_and_update_shared(content); - Ok(cell.cell.into()) -} - -/// Cells a value in a cell with a given key. A key MUST only be used once for -/// the whole application. -/// -/// This allows to create singleton Vcs for values while avoiding to pass the -/// whole value as argument and creating a large task key. -pub async fn global_keyed_cell( - key: K, - content: T, -) -> Result> { - let cell = KeyedCell::new_global(key.into_concrete(), T::get_value_type_id()).await?; - cell.cell_ref.compare_and_update_shared(content); - Ok(cell.cell.into()) -} diff --git a/crates/turbo-tasks/src/lib.rs b/crates/turbo-tasks/src/lib.rs index 6c67aae0aab27..20406afd422e5 100644 --- a/crates/turbo-tasks/src/lib.rs +++ b/crates/turbo-tasks/src/lib.rs @@ -48,7 +48,6 @@ mod id; mod id_factory; mod invalidation; mod join_iter_ext; -mod keyed_cell; #[doc(hidden)] pub mod macro_helpers; mod magic_any; @@ -85,7 +84,6 @@ pub use invalidation::{ DynamicEqHash, InvalidationReason, InvalidationReasonKind, InvalidationReasonSet, }; pub use join_iter_ext::{JoinIterExt, TryFlatJoinIterExt, TryJoinIterExt}; -pub use keyed_cell::{global_keyed_cell, keyed_cell}; pub use manager::{ dynamic_call, emit, get_invalidator, mark_finished, mark_stateful, prevent_gc, run_once, run_once_with_reason, spawn_blocking, spawn_thread, trait_call, turbo_tasks, CurrentCellRef, diff --git a/crates/turbopack-core/src/chunk/chunking.rs b/crates/turbopack-core/src/chunk/chunking.rs index bfdb09e339406..c359c0c038bab 100644 --- a/crates/turbopack-core/src/chunk/chunking.rs +++ b/crates/turbopack-core/src/chunk/chunking.rs @@ -141,8 +141,7 @@ async fn handle_split_group( }) } -/// Creates a chunk with the given `chunk_items. `key` should be unique and is -/// used with [keyed_cell] to place the chunk items into a cell. +/// Creates a chunk with the given `chunk_items. `key` should be unique. #[tracing::instrument(level = Level::TRACE, skip_all, fields(key = display(key)))] async fn make_chunk( chunk_items: Vec,