Created
May 18, 2015 17:07
-
-
Save Horusiath/2f6deda8daae44f37c16 to your computer and use it in GitHub Desktop.
Akka.NET F# Actor with state
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 State = { X: int; Y: int } | |
let system = ConfigurationFactory.Default() |> System.create "FSharpActors" | |
let aref = | |
spawn system "actor" | |
<| fun mailbox -> | |
let rec loop state = | |
actor { | |
let! msg = mailbox.Receive() | |
// ... do something | |
return! loop { state with X = state.X + msg } | |
} | |
loop { X = 0; Y = 0} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment