-
-
Save dustinlacewell-wk/54c7591fde643d12e5d7bb0571decfd1 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
let cell (x: 'a) : Job<Cell<'a>> = job { | |
let c = {reqCh = Ch (); replyCh = Ch ()} | |
let rec server x = job { | |
let! req = Ch.take c.reqCh | |
match req with | |
| Get -> | |
do! Ch.give c.replyCh x | |
return! server x | |
| Put x -> | |
return! server x | |
} | |
do! Job.start (server x) | |
return c | |
} |
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
let create (x: 'a) : Job<Cell<'a>> = Job.delay <| fun () -> | |
let c = {reqCh = Ch (); replyCh = Ch ()} | |
let rec server x = | |
Ch.take c.reqCh >>= function | |
| Get -> | |
Ch.give c.replyCh x >>=. server x | |
| Put x -> server x | |
Job.start (server x) >>-. c |
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
let create x = Job.delay <| fun () -> | |
let c = {reqCh = Ch (); replyCh = Ch ()} | |
Job.iterateServer x <| fun x -> | |
c.reqCh >>= function | |
| Get -> c.replyCh *<- x >>-. x | |
| Put x -> Job.result x | |
>>-. c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment