[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
# multichannel A mpmc priority multi channel with dynamic channel registration and freezing. ## Installation Add to your Cargo.toml file: ```toml [dependencies] multichannel = "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 ```rust use multichannel::DynMultiReceiver; #[derive(Debug)] enum Msg { Shutdown, IntegerData(i32), FloatingData(f32), } #[derive(Clone, PartialEq, Eq, PartialOrd, Ord)] enum Priority { High, Low, } fn main() { let mrx = DynMultiReceiver::