Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing a std::sync::Weak instead of a std::sync::Arc into UTransport::register_listener to support automatic knowledge of registration drop #200

Open
PLeVasseur opened this issue Aug 28, 2024 · 0 comments

Comments

@PLeVasseur
Copy link
Contributor

One aspect I really like about the up-cpp uP-L1 Transport API is that they have a concept of a Connection which gives them a nice API where even if they do not unregister_listener, the holder of the other end of the Connection can drop it in order to make the transport unable to call it anymore.

I think we could do the same in Rust by passing in a std::sync::Weak<dyn UListener> such that if the entity which is orchestrating the the UTransport wanted it to no longer be able to call it and in fact deregister, it would be possible to know that when the implementation attempted to call Weak::upgrade().

Just something going through my mind as I looked at how I implemented UTransport to take an Arc<dyn UListener> a while ago.

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

No branches or pull requests

1 participant