One Consumer, Multiple Producers in F#

I have been learning F# by reading the Expert F# 4.0 book by Don Syme, Adam Granicz, et al. I am really enjoying the concurrency chapter and decided to take on a small challenge involving agents (MailboxProcessor). I settled on the following requirements: 1 consumer agent with two-way communication accepts arrays of doubles and stores their sum and count internally allows other to fetch the current average 4 producer agents generate arrays of doubles sends them to the consumer agent fetches the current sum and count waits for a specific interval then generates next one Stats and Messages Let's start by defining a Stats type that will store our sum and count: type Stats = { Count: int; Sum: double; } And also the message type, that our StatsAgent will accept in order to interact with the outside world: type Msg = | Incr of double | Fetch of AsyncReplyChannel<Stats> | Die I don't have any particular comments on the above....

January 5, 2020 ยท 4 min