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

Re: [Xen-devel] [PATCH v3-RESEND 20/28] libxl: ocaml: allow device operations to be called asynchronously



On Wed, 2013-11-06 at 11:46 +0000, Rob Hoes wrote:
> > On Mon, 2013-10-21 at 14:32 +0100, Rob Hoes wrote:
> > > Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>
> > > ---
> > >  tools/ocaml/libs/xl/genwrap.py       |    6 +++---
> > >  tools/ocaml/libs/xl/xenlight_stubs.c |   14 +++++++++++---
> > >  2 files changed, 14 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/tools/ocaml/libs/xl/genwrap.py
> > > b/tools/ocaml/libs/xl/genwrap.py index daeffdf..721a336 100644
> > > --- a/tools/ocaml/libs/xl/genwrap.py
> > > +++ b/tools/ocaml/libs/xl/genwrap.py
> > > @@ -22,9 +22,9 @@ builtins = {
> > >      "libxl_cpuid_policy_list": ("unit",                "%(c)s = 0",
> > "Val_unit"),
> > >      }
> > >
> > > -DEVICE_FUNCTIONS = [ ("add",            ["ctx", "t", "domid", "unit"]),
> > > -                     ("remove",         ["ctx", "t", "domid", "unit"]),
> > > -                     ("destroy",        ["ctx", "t", "domid", "unit"]),
> > > +DEVICE_FUNCTIONS = [ ("add",            ["ctx", "t", "domid", 
> > > "?async:'a",
> > "unit", "unit"]),
> > > +                     ("remove",         ["ctx", "t", "domid", 
> > > "?async:'a", "unit", "unit"]),
> > > +                     ("destroy",        ["ctx", "t", "domid", 
> > > "?async:'a", "unit", "unit"]),
> > 
> > I probably don't speak enough ocaml to make heads or tails of it but can you
> > include the resulting ocaml type in the changelog? Is it really
> >         ctx-> t -> ?async -> () -> ()
> > ?   
> > 
> > I guess I don't fully grok "-> ()" if it can chain like that ;-)
> 
> The type of the function is "ctx-> t -> domid -> ?async -> () -> ()".
> The last () is the return type. The one before that is the type of the
> last argument of the function, which means you always have to call the
> function with () at the end. This used to mark "the end" of the
> function. It is not allowed in OCaml for functions to have optional
> arguments at the end.

Ah, yes, someone taught me that once before! 

[...]
> So another option would be to move the ?async argument further to the
> left, and skip the extra (), e.g. "ctx -> ?async -> t -> domid -> ()".
> But I wanted to keep the async stuff at the end (like in the libxl
> function), and adding a () is quite common in OCaml.

Right, assuming you are happy that the ordering you have is logical from
an ocaml pov (which may differ from libxl/C) it sounds fine to me.

Thanks for (re)educating me!

Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

Ian.



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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