Chapter 15. An introduction to message-passing concurrency

 

This chapter covers

  • Why shared mutable state is sometimes required
  • Understanding message-passing concurrency
  • Programming with agents in C#
  • Hiding agent-based implementations behind conventional APIs

Every seasoned developer has some first-hand experience of how difficult it can be to deal with problems such as deadlocks and race conditions. These are the hard problems that can arise in concurrent programs that involve shared mutable state (“shared,” that is, between processes that execute concurrently).

This is why, throughout this book, you’ve seen many examples of how to solve problems without making recourse to shared mutable state. Indeed, my recommendation is to avoid shared mutable state whenever possible, and FP provides an excellent paradigm for doing so.

In this chapter, you’ll see why it’s not always possible to avoid shared mutable state, and what strategies there are to synchronize access to shared mutable state. We’ll then concentrate on one of these strategies: agent-based concurrency, a style of concurrent programming that relies on message-passing between agents that “own” some state that they access in a single-threaded way. Programming with agents is popular with F# programmers, but you’ll see that it’s perfectly doable in C#.

15.1. The need for shared mutable state

 
 
 

15.2. Understanding message-passing concurrency

 
 

15.3. Functional APIs, agent-based implementations

 
 

15.4. Message-passing concurrency in LOB applications

 

Summary

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage