Last active
March 11, 2017 17:34
-
-
Save 17cupsofcoffee/710f1ddb518d8dc16b91a18765c1e99a to your computer and use it in GitHub Desktop.
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
open Akka.FSharp | |
open Akka.Actor | |
let system = System.create "system" (Configuration.defaultConfig()) | |
type GreeterMsg = | |
| Hello of string | |
| Goodbye of string | |
let greeter = spawn system "greeter" <| fun mailbox -> | |
let rec loop() = actor { | |
let! msg = mailbox.Receive() | |
match msg with | |
| Hello name -> printf "Hello, %s!\n" name | |
| Goodbye name -> printf "Goodbye, %s!\n" name | |
return! loop() | |
} | |
loop() | |
greeter <! Hello "Joe" | |
greeter <! Goodbye "Joe" | |
System.Console.ReadLine() |> ignore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment