[Feature]: Enforce service thread safety through automatic Send and Sync implementations
Maintainers usually reply within 1 day
@Javagedes is already working on this.
Since Nov 23, 2026.
Assessment
This issue has not been assessed yet.
Description
Feature Overview
Require the compiler to verify that Service<T> is Send + Sync, rather than asserting thread safety through unconditional unsafe implementations.
Services use Arc<T> for shared ownership and expose shared access through &T. However, atomic reference counting and shared-only access do not make arbitrary service implementations thread-safe. Interior mutability and destruction must also be safe across threads.
Solution Overview
Remove the unconditional unsafe Send and Sync implementations from Service<T> and allow Rust to derive these auto traits from its Arc field.
Because Arc<T> implements Send + Sync only when T: Send + Sync, require those bounds at the service abstraction boundary:
pub struct Service<T: ?Sized + Send + Sync + 'static> {
value: Arc<T>,
}
Propagate these requirements through service registration, conversions, parameter implementations, and generated code.
For trait-object services, express the requirement through service trait supertraits:
pub trait ExampleService: Send + Sync {
fn perform_work(&self);
}
This allows consumers to retain the existing form: Service<dyn ExampleService>.
Validation should include:
- Compile-time assertions that supported concrete and trait-object service handles implement Send + Sync.
- Compile-fail coverage rejecting service implementations that do not satisfy the bounds.
- Existing service registration, cloning, and destruction tests.
- Relevant workspace checks and supported-target builds.
Alternatives Considered
- Keep the unconditional unsafe implementations: Relies on an unenforced contract for every service implementation and permits non-thread-safe implementations to cross threads through safe APIs.
- Remove unsafe implementations without requiring bounds on services: Allows conditional auto-trait implementations, but still permits non-thread-safe services to be registered. This does not establish a uniform thread-safety requirement.
- Require all components to implement Send + Sync: Broader than necessary. Components are managed on the BSP; services are the independently shared abstraction.
Urgency
Medium
Are you going to implement the feature request?
I will implement the feature
Do you need maintainer feedback?
No maintainer feedback needed
Anything else?
No response
- Dominant language
- Rust
- Stars
- 568
- Forks
- 63
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 60
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenDevicePartnership/patina
-
state:needs-owner state:needs-triage type:documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
OpenDevicePartnership/patina#1987 ·
Maintainers usually reply within 1 day
-
state:backlog state:needs-triage type:feature-request urgency:medium
Difficulty 5/5 Over a week Newbie friendliness 28/100
OpenDevicePartnership/patina#2039 ·
Maintainers usually reply within 1 day
-
Potential Major Update: Drop `Deref` from `Protocol<P>`Possibly taken @makubacki claimed this 7 days ago. Open
OpenDevicePartnership/patina#2036 · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
OpenDevicePartnership/patina#2024 ·
Maintainers usually reply within 1 day
-
state:backlog urgency:low
Difficulty 4/5 3-5 days Newbie friendliness 48/100
OpenDevicePartnership/patina#2019 ·
Maintainers usually reply within 1 day
All issues in OpenDevicePartnership/patina
Similar issues
-
platform:windows provider:antigravity-cli providers setup triaged wontfix
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
can1357/oh-my-pi#21349 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
erkamyaman/rea-games#246 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
aaif-goose/goose#13970 ·
Maintainers usually reply within 1 day
-
comp-documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ClickHouse/ClickHouse#136277 ·
Maintainers usually reply within 1 day