The Wikipedia article on sequential process exchange (CSP) contains a nice section that details key differences between CSP and the Actor model (F # Agents are based on the concurrency actor model). Two differences that stand out to you are absolutely necessary - synchronous and asynchronous, as well as recording on channels or a direct letter to the process.
It may be possible, but it looks difficult. At the most fundamental level, CSP requires completely synchronous communication between processes, while the F # agent (MailboxProcessor) is asynchronous, so you will need to create a system that forces synchronous communication between F # agents. A possible solution would be to use the PostAndReply function.
The following big difference (and perhaps the most difficult to overcome): CSP writes to a specific channel, while the F # actor model you write messages to a specific actor. In other words, if you have two processes A and B : using F # A agents, a message will be sent explicitly indicating B.post(<msg>) , while in CSP A will write a message to a channel named chan and B will It is said to read explicitly from a channel named chan (note that in CSP the communication channels are process independent, whereas in the F # agent model the communication channel is identical to the receiving agent). This seems like a much more difficult difference to overcome. Just giving up and thinking (I donβt know if this will actually work well): one possibility might be to rethink what the F # agent is: instead of the Agent acting as a process, there are agents that act as a CSP channel.
For anyone interested in CSP, Clojure core.async is based on CSP, and Brave Clojure has a pretty good tutorial that helps explain how CSP works.
egerhard
source share