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

Re: [Xen-API] [Xen-devel] [PATCH 10 of 15] libxc/ocaml: Add simple binding for xentoollog (output only)



On Thu, 2012-11-29 at 18:20 +0000, Anil Madhavapeddy wrote:
> On 29 Nov 2012, at 18:03, Ian Campbell <Ian.Campbell@xxxxxxxxxx> wrote:
> > 
> > Another idea might be to make the bindings use the async interfaces
> > wherever possible by default, by definition anything potentially
> > blocking has supports this and that would avoid the need for
> > enter/leave, but at the expense of making the ocaml callers ugly
> > perhaps? Or maybe this sort of thing ends up looking very natural in
> > ocaml? Depends on your application's event mechanism I suspect.
> > 
> > Last half witted idea: everything could be async but the bindings
> > include the loop to wait for the async event, i.e. effectively making
> > the call sync again. This sounds silly but it might allow better control
> > over the placement of enter/leave vs callbacks, since you would just
> > drop it over libxl_event_wait?
> 
> Making everything explicitly async and non-blocking is by far the
> preferred solution in terms of stability, as it largely removes the
> need to worry about the GC interface and thread interactions.
> 
> There are several libraries to wrap async interfaces in convenient
> synchronous programming, most notably Lwt (http://ocsigen.org/lwt).

I'll have to take your word for that ;-)

> With this interface, all the OCaml callbacks are implemented in
> OCaml, and it just needs a select/epoll or equivalent to wake up
> sleeping threads when an IO event occurs.

On the libxl side you'd want to be using the ao_how thing described in
libxl.h[0] and probably the event loop stuff in libxl_event.h[1]. My gut
feeling is that you'd want to go the libxl_osevent_register_hooks route
to integrate libxl into lwt's event loop rather than the
libxl_osevent_{before,after}poll option.

[0] 
http://xenbits.xen.org/hg/xen-unstable.hg/file/1c69c938f641/tools/libxl/libxl.h#l377
[1] 
http://xenbits.xen.org/hg/xen-unstable.hg/file/1c69c938f641/tools/libxl/libxl_event.h

Ian.

> 
> Dave has already done some bindings to Lwt, so I've CCed him...
> 
> -anil
> 



_______________________________________________
Xen-api mailing list
Xen-api@xxxxxxxxxxxxx
http://lists.xen.org/cgi-bin/mailman/listinfo/xen-api


 


Rackspace

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