Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // setup actor system
- use system = ActorSystem.Configure()
- .Playground()
- .Register(Assembly.GetExecutingAssembly())
- .Done()
- // get uniq actor by name
- let counter = system.ActorOf<Counter>("realtime-consistent-counter")
- let writeJob() = task {
- printfn "send Increment message which should take 5 sec to finish."
- do! counter <! Increment // this message is not reentrant which means blocking operation
- printfn "send Increment message which should take 5 sec to finish."
- do! counter <! Increment
- printfn "send Increment message which should take 5 sec to finish."
- do! counter <! Increment
- }
- let readJob() = task {
- let mutable count = 0
- while count < 3 do
- let! result = counter <? GetCount // this message is reentrant which means not blocking operation
- count <- result
- printfn "current value is %d" count
- printfn "job is finished."
- }
- writeJob() |> ignore
- Task.run(readJob) |> ignore
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement