Skip to content

Add exclusive file close and bounded cleanup submission. - #29

Merged
samuel-williams-shopify merged 3 commits into
mainfrom
feat/file-close
Oct 17, 2026
Merged

samuel-williams-shopify merged 3 commits into
mainfrom
feat/file-close

Conversation

@samuel-williams-shopify

Copy link
Copy Markdown
Contributor

Add explicit file_close(file).await and file_close_submit(file).await, with a commented example showing how to request cancellation, await the outstanding operation, and then close safely.

Both methods consume exclusive ownership. Concrete backends now expose a non-clonable FileHandle instead of Arc<std::fs::File>; backend operations retain private ownership until they finish. Closing while an abandoned operation still retains the file panics, without interrupting that operation or introducing a per-file registry. Backend resource references are released before completion wakes the caller.

Close waits for bounded admission and reports execution errors. The _submit variant waits only for admission and discards execution errors. Accepted jobs survive waiter abandonment and run on a separate cleanup pool; native shutdown outside workers and awaited Tokio shutdown drain them. Native destruction from a future or blocking-pool worker requests shutdown without waiting on its own work. All backends initially use blocking close syscalls; native io_uring close SQEs and CQE suppression remain future optimizations.

The example in crates/executor/examples/file_close.rs explains shared cancellation handles, completion races, why dropping a future does not establish completion, and closing before propagating the read result. It runs against native and enabled Tokio backends. The design notes, simulator, and migration guidance reflect the new required File methods and resource type.

@samuel-williams-shopify
samuel-williams-shopify merged commit 093e03e into main Oct 17, 2026
18 checks passed
@samuel-williams-shopify
samuel-williams-shopify deleted the feat/file-close branch October 17, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant