Created
October 18, 2013 14:38
-
-
Save FoleyAxel/7042524 to your computer and use it in GitHub Desktop.
type mailbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type resultMsg = | |
| | Add of string | |
| | Fetch of AsyncReplyChannel<Set<string>> | |
| type resultContainer() = | |
| let innerContainer = | |
| MailboxProcessor.Start(fun inbox -> | |
| let rec loop (n:Set<string>) = | |
| async { let! msg = inbox.Receive() | |
| match msg with | |
| | Add x -> return! loop (n.Add x) | |
| | Fetch(reply) -> | |
| reply.Reply(n); | |
| return! loop n } | |
| loop Set.empty) | |
| member this.Add(x) = innerContainer.Post(Add x) | |
| member this.Fetch() = innerContainer.PostAndReply((fun reply -> Fetch(reply)), timeout = 2000) |
Author
FoleyAxel
commented
Oct 18, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment