The current design allows each channel to have multiple subscribers, which is a key strength for broadcasting. However, it also imposes a requirement: the messages must either implement Clone or be wrapped in shared references (e.g., Arc). While this approach supports broad use cases, it can be cumbersome for scenarios where only one subscriber per channel is needed.
In many systems, a "one-channel-per-subscriber" model is quite popular—for instance, threads often use their own dedicated channel to receive data. In such a model, cloning messages is unnecessary, as the sender can directly send owned messages to the subscriber.
To support this more efficiently, we could introduce a new data structure tailored for single-subscriber channels. This structure would enforce a one-subscriber-per-channel policy and allow direct message ownership transfers without wrapping in shared references or requiring Clone implementations.
This enhancement would:
- Reduce unnecessary data copying in single-subscriber use cases.
- Provide a more intuitive option for thread-to-thread communication with simpler semantics.
- Improve performance for workloads where only one subscriber is expected.
This would complement the existing NotifierHub rather than replace it, providing users with the flexibility to choose the most appropriate channel type for their needs.
The current design allows each channel to have multiple subscribers, which is a key strength for broadcasting. However, it also imposes a requirement: the messages must either implement Clone or be wrapped in shared references (e.g., Arc). While this approach supports broad use cases, it can be cumbersome for scenarios where only one subscriber per channel is needed.
In many systems, a "one-channel-per-subscriber" model is quite popular—for instance, threads often use their own dedicated channel to receive data. In such a model, cloning messages is unnecessary, as the sender can directly send owned messages to the subscriber.
To support this more efficiently, we could introduce a new data structure tailored for single-subscriber channels. This structure would enforce a one-subscriber-per-channel policy and allow direct message ownership transfers without wrapping in shared references or requiring Clone implementations.
This enhancement would:
This would complement the existing NotifierHub rather than replace it, providing users with the flexibility to choose the most appropriate channel type for their needs.