-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support creating differently-typed recipients in Addr::recipient()
...within bounds that that M: Into<N> for Recipient<M> for Actor<Message = N>. Fixes #11 (in its narrow sense) without creating multiple channels per actor and without boxing the messages transferred. Has been made possible by removal of the ability to retrieve back the failed-to-send message in one of the earlier commits. The whole trick is to box crossbeam `Sender<M>` into `Arc<dyn SenderTrait<M>>` in `Receiver`, and implementing `SenderTrait<M>` for crossbeam `Sender` and for boxed version of itself (!), second time with ability to convert `M`. All generic parameters in the echo example have disappeared without losing any flexibility, yay! Speaking strict semver, this is an API-breaking change, but e.g. the media_pipeline compiles and works unchanged. v2: make the change smaller and simpler by not messing up with `GenericReceiver`. Enables nicer API and keeping `SenderTrait` private, at the small expense of one extra boxing when creating `Addr`, and one extra pointer indirection when calling send() family of functions. All that thanks to @skywhale's clever question.
- Loading branch information
Showing
2 changed files
with
78 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters