feat: Improve thread_aware APIs and anyspawn rt compat.#403
feat: Improve thread_aware APIs and anyspawn rt compat.#403ralfbiedert merged 21 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR upgrades the workspace to thread_aware v0.7.0 (breaking), updating downstream crates (tick, uniflight, bytesbuf, http_extensions, seatbelt, etc.) to the new in-place ThreadAware::relocate(&mut self, Option<Affinity>, Affinity) API and the unified Affinity type. It also refactors anyspawn to a new custom-spawner model (SpawnCustom) and expands thread_aware to better support dyn ThreadAware via Arc<T, S>.
Changes:
thread_aware: replacerelocated(self, MemoryAffinity, PinnedAffinity) -> Selfwith in-placerelocate(&mut self, Option<Affinity>, Affinity), removeMemoryAffinity/PinnedAffinity, and addArc<T, S>support forT: ?Sizedplus clone-fn support for trait objects.- Update
tick,uniflight,bytesbuf,http_extensions,seatbelt, etc. to compile againstthread_awarev0.7.0 and refresh docs/snapshots accordingly. anyspawn: redesign custom spawning aroundSpawnCustom+ layered builder; introducespawn_anywherebased on thread-aware async closures.
Reviewed changes
Copilot reviewed 98 out of 99 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/uniflight/src/lib.rs | Update ThreadAware impl/tests to new relocate + Affinity API. |
| crates/uniflight/README.md | Refresh generated docs/links for new thread_aware version. |
| crates/tick/src/state.rs | Migrate ThreadAware impls from relocated to in-place relocate. |
| crates/tick/src/snapshots/tick__clock__tests__debug_alive_system_clock_relocated.snap | Snapshot update for PinnedAffinity → Affinity debug output. |
| crates/tick/src/runtime/mod.rs | Update docs/examples to use ThreadAware::relocate. |
| crates/tick/src/runtime/inactive_clock.rs | Migrate InactiveClock relocation to in-place API. |
| crates/tick/src/lib.rs | Update thread-aware helper macro to new relocate signature. |
| crates/tick/src/error.rs | Update relocation test to in-place relocate. |
| crates/tick/src/clock.rs | Convert clock relocation and related tests to new API. |
| crates/tick/README.md | Refresh generated docs/links for thread_aware v0.7.0. |
| crates/thread_aware/tests/transfer_pass.rs | Update derive test to new relocate API and trait import. |
| crates/thread_aware/tests/dyn_trait.rs | Add coverage for Arc<dyn ThreadAware, _> constructors. |
| crates/thread_aware/tests/derive_compiles.rs | Update derive compilation test to in-place relocation. |
| crates/thread_aware/src/wrappers.rs | Update Unaware to new relocate API and add Send bound. |
| crates/thread_aware/src/registry.rs | Replace stored affinities with Affinity and return Option<Affinity>. |
| crates/thread_aware/src/lib.rs | Update docs/re-exports; adjust derive docs to relocate. |
| crates/thread_aware/src/impls.rs | Convert standard impls to in-place relocation; add Box<T> impl. |
| crates/thread_aware/src/core.rs | Redefine ThreadAware as Send + in-place relocate. |
| crates/thread_aware/src/closure/mod.rs | Rename closure traits/types; add async thread-aware closure support. |
| crates/thread_aware/src/closure/erased.rs | Update erased closure wrapper to new closure traits + relocate. |
| crates/thread_aware/src/cell/tests.rs | Update cell tests to new API and new PerCore::new usage. |
| crates/thread_aware/src/cell/storage.rs | Update storage strategy API to use Affinity. |
| crates/thread_aware/src/cell/mod.rs | Make Arc<T, S> support ?Sized; add boxed ctor + clone-fn factory path. |
| crates/thread_aware/src/cell/factory.rs | Add erased clone-fn factory to support dyn ThreadAware cloning/relocation. |
| crates/thread_aware/src/cell/builtin.rs | Update strategy implementations to accept Affinity. |
| crates/thread_aware/src/affinity.rs | Remove MemoryAffinity/PinnedAffinity; introduce unified Affinity. |
| crates/thread_aware/README.md | Refresh generated README for v0.7.0 and new API terminology. |
| crates/thread_aware/CHANGELOG.md | Document breaking changes for upcoming release. |
| crates/thread_aware/Cargo.toml | Bump crate version to 0.7.0; add futures dev-dependency for tests. |
| crates/thread_aware_macros/Cargo.toml | Bump macros crate to 0.7.0. |
| crates/thread_aware_macros_impl/tests/snapshots/derive__tuple_struct_and_enum.snap | Snapshot updates for new derive output (relocate). |
| crates/thread_aware_macros_impl/tests/snapshots/derive__struct_unit.snap | Snapshot updates for new derive output (relocate). |
| crates/thread_aware_macros_impl/tests/snapshots/derive__struct_basic.snap | Snapshot updates for new derive output (relocate). |
| crates/thread_aware_macros_impl/tests/snapshots/derive__struct_attr_skip.snap | Snapshot updates for new derive output (relocate). |
| crates/thread_aware_macros_impl/tests/snapshots/derive__phantom_data_unnamed_fields.snap | Snapshot updates for new derive output (relocate). |
| crates/thread_aware_macros_impl/tests/snapshots/derive__phantom_data_named_fields.snap | Snapshot updates for new derive output (relocate). |
| crates/thread_aware_macros_impl/tests/snapshots/derive__generics_tuple_usage_adds_bound.snap | Snapshot updates for new derive output (relocate). |
| crates/thread_aware_macros_impl/tests/snapshots/derive__generics_ref_usage_adds_bound.snap | Snapshot updates for new derive output (relocate). |
| crates/thread_aware_macros_impl/tests/snapshots/derive__generics_prebound_no_dup.snap | Snapshot updates for new derive output (relocate). |
| crates/thread_aware_macros_impl/tests/snapshots/derive__generics_prebound_fq_no_dup.snap | Snapshot updates for new derive output (relocate). |
| crates/thread_aware_macros_impl/tests/snapshots/derive__generics_paren_adds_bound.snap | Snapshot updates for new derive output (relocate). |
| crates/thread_aware_macros_impl/tests/snapshots/derive__generics_group_usage_adds_bound.snap | Snapshot updates for new derive output (relocate). |
| crates/thread_aware_macros_impl/tests/snapshots/derive__generics_array_usage_adds_bound.snap | Snapshot updates for new derive output (relocate). |
| crates/thread_aware_macros_impl/tests/snapshots/derive__generics_add_bounds.snap | Snapshot updates for new derive output (relocate). |
| crates/thread_aware_macros_impl/tests/snapshots/derive__enum_unnamed_phantom_data.snap | Snapshot updates for new derive output (relocate). |
| crates/thread_aware_macros_impl/tests/snapshots/derive__enum_named_phantom_data.snap | Snapshot updates for new derive output (relocate). |
| crates/thread_aware_macros_impl/src/struct_gen.rs | Update struct derive generation to in-place field relocation. |
| crates/thread_aware_macros_impl/src/lib.rs | Update derive entrypoint for new trait signature/types; remove old helper. |
| crates/thread_aware_macros_impl/src/enum_gen.rs | Update enum derive generation to in-place field relocation. |
| crates/thread_aware_macros_impl/Cargo.toml | Bump macros-impl crate to 0.7.0. |
| crates/templated_uri/src/uri.rs | Doc import ordering/formatting tweaks. |
| crates/templated_uri/src/path_and_query_template.rs | Doc import ordering/formatting tweaks. |
| crates/templated_uri/src/lib.rs | Re-export order and doc import ordering tweaks. |
| crates/templated_uri/src/base_uri.rs | Doc formatting for readability. |
| crates/templated_uri/src/_documentation/recipes.rs | Doc formatting/import ordering tweaks. |
| crates/templated_uri/README.md | Refresh generated README payload + doc import ordering tweaks. |
| crates/templated_uri/examples/classified_templating.rs | Import ordering/formatting tweaks. |
| crates/seatbelt/src/retry/mod.rs | Move deprecated re-export to end of module. |
| crates/seatbelt/src/hedging/telemetry.rs | Import ordering tweaks + minor formatting changes. |
| crates/seatbelt/src/hedging/service.rs | Minor formatting change. |
| crates/seatbelt/src/hedging/mod.rs | Move deprecated re-export to end of module. |
| crates/seatbelt/src/hedging/layer.rs | Import grouping tweak. |
| crates/seatbelt/src/hedging/args.rs | Import ordering tweak. |
| crates/seatbelt/src/fallback/mod.rs | Doc formatting change. |
| crates/seatbelt/src/fallback/layer.rs | Import ordering tweak. |
| crates/seatbelt/src/context.rs | Update ThreadAware impl to new relocate + Affinity API. |
| crates/seatbelt/src/chaos/latency/mod.rs | Doc formatting tweak. |
| crates/seatbelt/examples/retry_advanced.rs | Import grouping tweak. |
| crates/recoverable/src/io.rs | Test import ordering tweak. |
| crates/ohno/src/lib.rs | Re-export ordering tweak. |
| crates/ohno/src/error_label.rs | Test import ordering tweak. |
| crates/http_extensions/src/http_response_builder.rs | Doc formatting tweak. |
| crates/http_extensions/src/http_request_builder.rs | Doc formatting tweak. |
| crates/http_extensions/src/fake_handler.rs | Update ThreadAware impl to new relocate + Affinity API + doc formatting. |
| crates/http_extensions/src/extensions/request_ext.rs | Import ordering tweak. |
| crates/http_extensions/src/error.rs | Update ThreadAware impl to new relocate + Affinity API + doc formatting. |
| crates/http_extensions/src/body/options.rs | Doc formatting tweak. |
| crates/http_extensions/src/body/builder.rs | Import ordering tweak + minor test formatting. |
| crates/http_extensions/src/_documentation/recipes.rs | Doc formatting/import ordering tweaks. |
| crates/cachet/src/transform/tier.rs | Import ordering tweak. |
| crates/cachet/src/transform/codec.rs | Doc import ordering tweak. |
| crates/cachet_tier/src/dynamic.rs | Import grouping tweak. |
| crates/cachet_memory/src/tier.rs | Import ordering tweak. |
| crates/cachet_memory/src/builder.rs | Doc import ordering tweak. |
| crates/bytesbuf/src/mem/global.rs | Update ThreadAware impl/tests to new in-place relocation API. |
| crates/anyspawn/tests/spawner.rs | Update tests to new custom spawner API; keep cfg(not(miri)). |
| crates/anyspawn/tests/relocation.rs | Rewrite relocation tests for new SpawnCustom model. |
| crates/anyspawn/tests/builder.rs | Replace snapshot-based tests with behavioral tokio tests. |
| crates/anyspawn/src/spawner.rs | Redesign spawner API to use SpawnCustom; add spawn_anywhere; drop new_thread_aware. |
| crates/anyspawn/src/lib.rs | Update crate docs/exports for new spawning model. |
| crates/anyspawn/src/custom.rs | Introduce SpawnCustom trait and internal bridging types for spawn_anywhere. |
| crates/anyspawn/src/builder.rs | Redesign builder layering around future transformation and SpawnCustom. |
| crates/anyspawn/README.md | Refresh generated README payload + dependency info. |
| crates/anyspawn/examples/thread_aware.rs | Update example from new_thread_aware to per-core state via SpawnCustom. |
| crates/anyspawn/examples/otel_context.rs | Update example to new builder layer signature. |
| crates/anyspawn/examples/custom.rs | Update example from closure-based custom spawning to SpawnCustom. |
| crates/anyspawn/Cargo.toml | Bump version to 0.4.0; adjust dev-deps and test ordering. |
| Cargo.toml | Bump workspace versions for thread_aware* and anyspawn. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #403 +/- ##
========================================
Coverage 100.0% 100.0%
========================================
Files 226 227 +1
Lines 16334 16740 +406
========================================
+ Hits 16334 16740 +406 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 99 out of 100 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 101 out of 102 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ba6c6f2 to
fce4dfe
Compare
Allow for dynamic creation.
…an Option<Affinity> where needed. Make anyspawn use new ThreadAware design to allow for better spawn_anywhere.
- Replace em-dashes with hyphens in doc comments (spellcheck) - Sort anyspawn Cargo.toml dependencies (cargo-sort) - Fix stale is_unknown()/memory_affinities references in registry tests - Allow dead_code/unused lints in transfer_pass.rs compile test - Update anyspawn external types allowlist for Affinity rename Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Combine duplicate D: ThreadAware + D: 'static bounds (type_repetition_in_bounds) - Fix bench to use SpawnCustom impl instead of closure - Use Arc::clone() instead of .clone() on ref-counted pointers - Add reason to allow attributes (allow_attributes_without_reason) - Allow items_after_statements in test code - Fix stale 'relocated' references in doc comments - Wrap ThreadAware in backticks in doc comments (spellcheck) - Use Self in destructuring pattern (use_self) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add tests using Tracker/Seed types with observable relocate behavior to catch cargo-mutants replacing relocate bodies with no-ops. Coverage: - impls.rs: Option, Result, Vec, Box, HashMap - closure/mod.rs: all 6 closure types (sync + async) - closure/erased.rs: ErasedClosureOnce + Wrapper - cell/tests.rs: BoxedRelocate via new_with factory - anyspawn/builder.rs: spawn_anywhere + relocate with layers - anyspawn/relocation.rs: SpawnAnywhereTask data relocation - bytesbuf, uniflight, seatbelt: skip trivial delegations Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix redundant_clone warnings with #[expect] in cell tests - Fix usize-to-i32 cast with try_from in cell tests - Add unit tests for Layered::relocate and LayeredTask::relocate in builder.rs to catch remaining 2 missed mutants Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Backtick-wrap spawn_anywhere in doc comment (clippy doc_markdown) - Rephrase 'dereferencing' to avoid spellcheck failure - Convert doc comments to regular comments on test function to avoid spellcheck scanning test prose Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use non-Copy types (String) for async closure coverage tests and ensure originals are used after cloning to avoid redundant_clone lint. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
489e8ca to
117bbb7
Compare
|
let's merge this one first #407 |
I prefer to merge this one here first, because switching to nightly fmt is an automatic thing. Doing it the other way around means probably having to manually fix multiple rounds of merge conflicts. |
merging PR that have changes in random crates just because of formatting is a bigger issue, I would rather avoid that |
No description provided.