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

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

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Getting started with Databricks SQL

Python List Comprehension

Our World Are Proud To Announce We Are Currently Attending Holochain DevCamp 7

5/3 binary tree

Designing an ISV Partner Program Optimized for Enterprise Cloud

Keep it simple by dividing Partners into their two main types.

Kids Coding is successful in an Uncertain Future

Schedule a task in Spring Boot

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Greg Terzian

Greg Terzian

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

More from Medium

Rust Projects, Parsing and Validating

Low angle shot on a northern dock. Cloudy overcast skies and a pair of rusted nails sit in the foreground> They are placed on a dock in the shape of an X.

An HTTP Reverse Proxy in Rust with the actix-web framework

Todo service with rust actix sea-orm -Entity generation [Part 3]

An introduction into Rust. Part 4: Borrowing Ownership