On Wed, 4 Feb 2015 11:52:28 +0000, Thomas Leonard wrote: > > On 3 February 2015 at 23:16, Christophe Troestler > <[email protected]> wrote: > > On Mon, 2 Feb 2015 12:30:39 +0000, Thomas Leonard wrote: > >> > >> let bind t f = > >> let t = repr t in > >> match t.state with > >> | Return v -> > >> f v > >> | Fail _ as state -> > >> thread { state } > >> | Sleep sleeper -> > >> let res = temp t in > >> let data = !current_data in > >> add_immutable_waiter sleeper > >> (function > >> | Return v -> current_data := data; connect res (try f v > >> with exn -> fail exn) > >> | Fail _ as state -> fast_connect res state > >> | _ -> assert false); > >> res > > > > Thanks for checking. At first, the difference of treatment between > > the two “f v” is a little odd. Do you happen to know the reason for > > it? > > I assume it's a speed optimisation
Thinking a bit more about this, I wonder whether it may be more fundamental: when the state is “Return”, the exception will travel the chain of calls of the same "thread" up until it reaches a handler — so one can dispense putting a handler —, when it is “Sleep”, it is possible that it escape the current thread. [Will read the rest later — at a meeting...] Best, C. _______________________________________________ MirageOS-devel mailing list [email protected] http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel
