Skip to content

Commit

Permalink
handle state serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Sep 4, 2024
1 parent 74f099d commit e6af7cd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
22 changes: 22 additions & 0 deletions turbopack/crates/turbo-tasks-backend/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,28 @@ impl Backend for TurboTasksBackend {
);
}

fn invalidate_serialization(
&self,
task_id: TaskId,
turbo_tasks: &dyn TurboTasksBackendApi<Self>,
) {
let ctx = self.execute_context(turbo_tasks);
let task = ctx.task(task_id);
let cell_data = task.iter().filter_map(|(key, value)| match (key, value) {
(CachedDataItemKey::CellData { cell }, CachedDataItemValue::CellData { value }) => {
Some(CachedDataUpdate {
task: task_id,
key: CachedDataItemKey::CellData { cell: *cell },
value: Some(CachedDataItemValue::CellData {
value: value.clone(),
}),
})
}
_ => None,
});
self.persisted_storage_log.lock().extend(cell_data);
}

fn get_task_description(&self, task: TaskId) -> std::string::String {
let task_type = self.lookup_task_type(task).expect("Task not found");
task_type.to_string()
Expand Down
8 changes: 8 additions & 0 deletions turbopack/crates/turbo-tasks-backend/src/utils/chunked_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ impl<T> ChunkedVec<T> {
}
}

impl<T> Extend<T> for ChunkedVec<T> {
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
for item in iter {
self.push(item);
}
}
}

fn chunk_size(chunk_index: usize) -> usize {
8 << chunk_index
}
Expand Down

0 comments on commit e6af7cd

Please sign in to comment.