Rust concurrency patterns: Still communicating by moving senders(like it’s 2018)

Gregory Terzian
May 5 · 12 min read

A core idea is left unchanged

Share your sender with other threads/components, and keep your receiver to yourself.

An example is introduced

A motive is questioned

A non-event-loop is encountered

https://github.com/servo/servo/blob/be84644bc0b854bc04e6eb4c2e300b1a8e59a234/components/layout_thread/lib.rs#L639

The benefits of a non-event-loop are clarified

A critical note is elaborated

The version at https://github.com/servo/servo/blob/af077f8cf7feeb3ae791be133e4b3a10bf9ef614/components/background_hang_monitor/background_hang_monitor.rs#L154

A straw man is exposed

A potential misunderstanding is clarified

A point is driven home

Share your sender with other threads/components, and keep your receiver to yourself.

https://github.com/servo/servo/blob/af077f8cf7feeb3ae791be133e4b3a10bf9ef614/components/background_hang_monitor/background_hang_monitor.rs#L231

A final word, or only the beginning?

Rust as a language doesn’t really have an opinion on how to do concurrency or parallelism. https://doc.rust-lang.org/nomicon/concurrency.html

And by the way

More reading

Gregory Terzian

Written by

I write in Python, Javascript, Rust, and English. Always for people to read. https://github.com/gterzian/

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade