let pipe_interleave () : unit Deferred.t =
let (rs, ws) = List.(unzip (map (range 0 10) ~f:(fun _ -> Pipe.create ()))) in
List.iteri ws ~f:(fun i w -> don't_wait_for (Pipe.write w i >>| fun () -> Pipe.close w));
let r = Pipe.interleave rs in
Pipe.iter r ~f:(fun i -> return (printf "read %d\n" i))