[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2-resend 22/30] libxl: ocaml: event management [and 1 more messages]

> I replied to v2 of this as follows:
> Ian Jackson writes ("Re: [Xen-devel] [PATCH v2-resend 22/30] libxl: ocaml:
> event management"):
> > Can you explain in a bit more detail how you expect to use this ?
> >
> > I'm very surprised that apparently the right interface to provide is
> > one which exposes the poll-based event loop machinery to ocaml.
> > Surely it would be better to plumb that in at a lower level.
> But I haven't had an answer.

Sorry, I had missed this... :(

> I think that whether this is the right approach depends on how event loops
> are traditionally done in ocaml.

Having bindings to the low-level functions libxl_osevent_register_hooks and 
related, allows us to run an event loop in OCaml; either one we write 
ourselves, or one that is available elsewhere.

We are currently running a straightforward, custom event loop in xenopsd. It 
simply maintains a list of fds and timeouts, and runs poll in a loop, as you 
would expect (see 
https://github.com/xapi-project/xenopsd/blob/master/xl/xenlight_events.ml for 
the full code).

The Lwt cooperative threads library (http://ocsigen.org/lwt/), which is quite 
popular these days, has an event loop that can be easily extended to poll any 
additional fds that we get from libxl. Lwt provides a "lightweight" threading 
model, which does not let you run any other (POSIX) threads in your 
application, and therefore excludes an event loop implemented in the C 
bindings. We have not ported xenopsd to use Lwt yet, but there were plans to do 
so in future.

Exposing the low-level event hooks in OCaml gives us the choice to implement 
either of the above options.

> I'm afraid, though, that in the absence of an explanation:
> Nacked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
> Thanks,
> Ian.
> PS Does anyone here know how Mirage handles event loops ?

I believe Mirage uses Lwt, and therefore probably uses its event loop.


Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.