Created
          May 25, 2015 15:32 
        
      - 
      
- 
        Save hodzanassredin/6979d9845bada2798fdc to your computer and use it in GitHub Desktop. 
    joinads deadlock
  
        
  
    
      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 FSharp.Joinads.Joins | |
| open System | |
| [<EntryPoint>] | |
| let main argv = | |
| // Construct channels implementing the buffer | |
| let put = Channel<string>("put") | |
| let put2 = Channel<string>("put2") | |
| let get = SyncChannel<string>("get") | |
| let get2 = SyncChannel<string>("get2") | |
| // Encode a join pattern over the channels | |
| let merge = Channel.merge put put2 | |
| let merge2 = Channel.merge put2 put | |
| let withOut1 = Channel.merge get merge | |
| let withOut2 = Channel.merge get2 merge2 | |
| let act1 = Channel.map (fun (repl:IReplyChannel<string>,value) ->[repl.Reply("first")]) withOut1 | |
| let act2 = Channel.map (fun (repl:IReplyChannel<string>,value) ->[repl.Reply("second")]) withOut2 | |
| // let choice = Channel.choice act1 act2 | |
| //Channel.run choice "choice" | |
| Channel.run act1 "act1" | |
| Channel.run act2 "act2" | |
| async { | |
| while true do | |
| let! repl = get.AsyncCall() | |
| printfn "got1: %s" repl } |> Async.Start | |
| async { | |
| while true do | |
| let! repl = get2.AsyncCall() | |
| printfn "got2: %s" repl } |> Async.Start | |
| // Store some values in 'put' channel | |
| put.Call(" put ") | |
| put2.Call(" put2") | |
| // Obtain value via the 'get' channel | |
| Console.ReadKey() |> ignore | |
| 0 // return an integer exit code | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment