pub async fn with_file_mutation_queue<T, E, F, Fut>(
file_path: &str,
cwd: &Path,
f: F,
) -> Result<T, E>Expand description
Serialize file mutation operations targeting the same file.
Operations for different files still run in parallel. This mirrors pi’s
withFileMutationQueue in file-mutation-queue.ts.
The implementation:
- Each file has a
Notifystored in a global map, representing the “next operation” signal. - An operation registers by replacing the entry with its own
Notify(for the operation after it), and picking up the previousNotifyto wait on. - When the operation finishes, it signals its own
Notify(which the next operation is waiting on) and, if it is still the latest entry, cleans up.