multichannel
A mpmc priority multi channel with dynamic channel registration and freezing.
Installation
Add to your Cargo.toml file:
[]
= "0.2.0"
Features
- Dynamic channel creation and removal
- Priority based message selection
- Weighted message selection
- Channel freezing
- Bounded and unbounded channels
- Thread safe
- No unsafe code
- Multi producer and multi consumer
Performance
The amount of functionality the DynMultiReceiver provides comes at a cost. Due to the freezing feature, every receive() call has a worst case of O(n) complexity, where n is the amount of channels. This is because the DynMultiReceiver has to iterate over all channels to find the highest priority channel with a message THAT IS NOT FROZEN. Otherwise using a heap would be a good idea, but the freezing feature makes this impossible.
So if you have a huge amount of channels and you are not using the freezing feature, you might want to consider using a different implementation. For most use cases, the performance should be good enough.
If you can implement your logic using only basic channels, you should do that. This implementation is meant for cases where you need more advanced features.
Hello World
use DynMultiReceiver;
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.