Future combinators

And now that we mentioned joins, it is actually possible to have two co-dependent futures. Maybe we have information from two files, we generate one future reading from each file, and then we want to combine the information from them. We don't need to block the thread for that; we can use the join() method, and the logic behind it will make sure that once the closure we write gets called, both futures will have received the final value.

This is really useful when creating concurrency dependency graphs. If you have many small computations that you want to parallelise, you can create a closure or a function for each of the parts, and then use join() and other methods, such as and_then(), to decide which computations need ...

Get Rust High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.