-
Notifications
You must be signed in to change notification settings - Fork 1
AsyncFP Transactions
Once you start using multiple threads, thread safety becomes an issue. Fortunately thread safety is handled implicitly by actors, but there is still one issues that occasionally needs to be dealt with--interleaving.
An actor will only process one message at a time--it is single threaded, though it does not use a dedicated thread. But when an actor sends a request to another actor, the actor may start processing another request or process the response to another request that was sent earlier. An actor is free to interleave the processing of multiple requests, though it can only actively process one request at a time. This is sometimes an issue that needs to be addressed.
The complication here is that AsyncFP actors must accept for processing all the requests that they receive. This is in contrast to Scala actors, which can select which messages they are ready to process. The AsyncFP answer is to use a different form of binding for requests which may conflict with other requests and to enqueue these requests until they can be processed without conflicts.
Transactions, which is to say requests which may conflict with other requests sent to the same actor, come in two flavors: Query and Update. The processing of a query can be interleaved with the processing of other queries, while the processing of an update can not be interleaved with the processing of any other transactions.