Created
February 8, 2012 02:00
-
-
Save davidgrenier/1764329 to your computer and use it in GitHub Desktop.
PostAndAsyncReply
This file contains 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 MessageWithResponse = | |
| GetNextNumber of AsyncReplyChannel<int> * int | |
let inbox = | |
MailboxProcessor.Start <| fun inbox -> | |
async { | |
while true do | |
let! (GetNextNumber(channel, num)) = inbox.Receive() | |
channel.Reply (num + 1) | |
};; | |
inbox.PostAndReply (fun channel -> GetNextNumber(channel, 3)) // retourne 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment