CON-382: Simplify concurrency guarantees#11
Conversation
a6cc82e to
e2459f8
Compare
e2459f8 to
5e80bca
Compare
There was a problem hiding this comment.
Pull request overview
This PR simplifies the concurrency model for the RTI Connector Rust bindings by removing the complex Acquire/Release pattern and replacing it with a simpler Mutex-based approach. The change improves user experience at the cost of minor performance overhead on synchronization operations.
Changes:
- Replaced RwLock-based acquire/release pattern with Arc for thread-safe connector access
- Removed lifetimes from Input and Output types, making them cloneable and easier to use
- Deprecated take_input/take_output methods in favor of simplified get_input/get_output
- Updated documentation to reflect the simplified threading model
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/connector.rs | Replaced complex ThreadSafeEntityHolder with Arc containing Mutex; removed acquire/release logic; deprecated take_* methods |
| src/input.rs | Removed lifetime parameter; changed to Arc-based ownership; removed Drop implementation; simplified native access |
| src/output.rs | Removed lifetime parameter; changed to Arc-based ownership; removed Drop implementation; simplified native access |
| src/ffi/mod.rs | Added Send implementation for FfiConnector to enable Arc<Mutex> |
| src/lib.rs | Added concurrency trait tests to verify Send + Sync implementations |
| tests/test_input.rs | Updated tests to expect concurrent get_input to succeed; changed take_input to get_input |
| tests/test_output.rs | Updated tests to expect concurrent get_output to succeed; changed take_output to get_output |
| tests/test_utils/context.rs | Removed lifetime from TestEntities struct |
| docs/guide/threading.md | Simplified threading documentation to reflect new model |
| docs/guide/connector.md | Updated note about multi-threaded access |
| docs/guide/input.md | Removed lifetime from type signatures |
| docs/guide/output.md | Removed lifetime from type signatures |
| docs/lib.md | Changed heading level from # to ## |
| examples/shapes/publisher.rs | Changed take_output to get_output |
| examples/shapes/subscriber.rs | Changed take_input to get_input |
| snippets/quickstart.rs | Removed lifetimes from type annotations |
| snippets/output/using_instance.rs | Removed lifetime from function signature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Also, general fixes to documentation
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 9 comments.
Comments suppressed due to low confidence (2)
examples/shapes/subscriber.rs:41
- The error context still says "Failed to take input" even though the code now calls
get_input. Updating this message will make failures easier to interpret when debugging.
let mut input = connector
.get_input(INPUT_NAME)
.map_err(|e| format!("Failed to take input: {}", e))?;
examples/shapes/publisher.rs:44
- The error context still says "Failed to take output" even though the code now calls
get_output. Consider updating the message so it matches the actual operation being performed.
let mut output = connector
.get_output(OUTPUT_NAME)
.map_err(|e| format!("Failed to take output: {}", e))?;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Reimplement Acquire/Release Remove Clone from Input/Output Remove unneeded threading guarantees
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
src/output.rs:155
- The lifetime parameter 'a in the Drop implementation is unnecessary and unused since Output no longer has any lifetime parameters. Consider removing it for clarity.
impl<'a> Drop for Output {
src/input.rs:321
- Grammar error: "This samples will be discard" should be "These samples will be discarded".
/// This samples will be discard by the [`Input`] next time either
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
We've discussed this offline and we have agreed that the current approach is robust enough.
See #12.