Skip to content

Instantly share code, notes, and snippets.

@Horusiath
Created May 18, 2015 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Horusiath/2f6deda8daae44f37c16 to your computer and use it in GitHub Desktop.
Save Horusiath/2f6deda8daae44f37c16 to your computer and use it in GitHub Desktop.
Akka.NET F# Actor with state
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