Limited resource multiple access in Rust

Hi,

I need to write piece of software that is kind of exposing single serial port over HTTP.
Since you can have only one serial port and possibly multiple users (albeit limited) that want to retrieve different data via serial port I need kind of queue where you can put command (got by http) and then executed and result returned to user back via http. I need some thread/future that will have access to serial port and some "channel' to send/receive data.

My problem is - how/what crates use to implement "multiple producers (threads) sending commands" -> single consumer thread with exclusive serial access ).
Such solution need some timeout option to avoid blocking whole queue when one command takes too much time.

I saw similar solution in go where there is goroutine running that have serial port opened and two channels.
On one you put command, on second you got result. Internally there is queue with timeouts etc ..

I don't need solution - just point me to some crates implementing non blocking queue/worker or similar solution.

2 Likes
3 Likes