O'Reilly logo

Mastering F# by Suhaib Fahad, Alfonso García-Caro Núñez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Actor programming with MailboxProcessor

The actor programming model is a concurrent programming technique that provides a powerful mechanism to encapsulate several concurrency features. The key principles of the actor model are as follows:

  • No shared state between actors
  • Async message passing between clients to actor or between actors
  • Mailbox to buffer incoming messages
  • React to received messages by executing function

The F# MailboxProcessor class is the implementation of the actor model in FSharp.Core, and it is essentially a dedicated message queue running its own thread. We can use the API for MailboxProcessor to Post/Receive messages synchronously or asynchronously. We can also consider it an agent with an internal state machine. Let's take look ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required