Summary

This chapter presented some powerful abstractions for asynchronous programming. We have seen how to encode latency with the Future type, how to avoid blocking with callbacks on futures, and how to compose values from multiple futures. We have learned that futures and promises are closely tied together and that promises allow interfacing with legacy callback-based systems. In cases, where blocking was unavoidable, we learned how to use the Await object and the blocking statement. Finally, we learned that the Scala Async library is a powerful alternative for expressing future computations more concisely.

Futures and promises only allow dealing with a single value at a time. What if an asynchronous computation produces more than a single value ...

Get Learning Concurrent Programming in Scala 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.