servo / ipc-channel

A multiprocess drop-in replacement for Rust channels
Apache License 2.0
857 stars 129 forks source link

Multiple senders #190

Open jrmuizel opened 6 years ago

jrmuizel commented 6 years ago

I'm probably missing it, but where's the code to prevent multiple senders from having the messages interleaved?

i.e. on unix the messages are not sent in a single write call so what code keeps the next sender on a different thread from starting it's writes before the previous sender has finished?

antrik commented 6 years ago

Sends on the main channel are atomic. When sending large messages that need fragmentation, a dedicated channel is created for that message. (See https://github.com/servo/ipc-channel/commit/ce7c296a3717b054060889b780f8638eb66ce970 for when this approach was originally introduced, and search for dedicated_tx/dedicated_rx in https://github.com/servo/ipc-channel/blob/master/src/platform/unix/mod.rs to see the current code.)