Re: [Felix-language] mutiplexer

2012-12-01 Thread john skaller
Here's much better version: /// // First, a simple fibre to copy from one channel to another noinline proc copy[T] (i:ischannel[T],o:oschannel[T]) () { while true do var x = read i; write (o,x); done } // Now, here's a multiplexor. proc mux[T] (inp:1->opt[ischannel[T]]

[Felix-language] mutiplexer

2012-11-30 Thread john skaller
here's how to do something like select(), i.e. read from one of several channels, which every is ready first: proc multiplex (i1:ischannel[int], i2:ischannel[int], o:oschannel[int]) { spawn_fthread { while true do var x = read i1; write (o,x); done }; spawn_fthread { while true do var x = read