Chapter 25
Futures and Promises
One of the major themes of Part I was that functional programming involves a shift from actions and mutability to functions and immutability, a major benefit of which is easier sharing of data across program components. In Part II, we have already seen in Chapters 22 to 24 that sharing mutable data among threads—and the resulting need for synchronization—is a great source of complexity in concurrent programming. This chapter and the next aim to show that concurrent code can be greatly simplified by leveraging functional programming principles. As before, it all begins with the use of pure functions as units of computation but is now executed by separate threads. Futures are a standard programming language construct ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access