Concurrency is an essential concept in modern programming. This challenge focuses on building a message processing system using Rust's channels and threads. You'll create a system where multiple producers send messages with different priority levels, and a single consumer processes and formats these messages.
Implement three key functions that work with a message processing system:
create_message_channel()
- Creates a channel for sending Message structscreate_producer_thread()
- Creates a thread that analyzes and forwards messagescreate_consumer_thread()
- Creates a thread that formats and collects messages[PRIORITY|SENDER_ID] CONTENT
where PRIORITY is one of: LOW, MED, HIGH, CRITunwrap()
main
function to see how the functions are used.Here are some tips to help you get started:
mpsc::channel()
to create the message channelthread::spawn
and move closureswhile let Ok(msg) = rx.recv()
for receivingformat!("[{}|{}] {}", priority, id, content)