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

Re: xmlm input function with blocking



Le lundi, 27 mai 2013 Ã 14:35, Anil Madhavapeddy a Ãcrit :

> xmlm lets custom input functions be defined:

This interface is useless crap, it doesn't solve any problem.  

Xmlm as it stands has a streaming but *blocking* interface and you cannot do 
anything about it.
  

> However, both Async and Lwt (and presumably Fut) need to signal that Fun 
> might block if data is temporarily unavailable.

Yes.  
  
> Do you have any thoughts on how to support this in xmlm streaming API? A 
> Would_block exception would be sufficient to signal a temporary failure, but 
> then there also needs to be a function to restart the Xmlm parser from within 
> the I/O loop.

Sure, that's exactly what non-blocking codecs solve [1]. If you use a `Manual 
source you provide the buffer to read from and the computation suspends and 
asks for more if it cannot proceed (Xmlm.input returns `Await).  

On my side, at the moment, only uutf [2] and jsonm [3] support that (and Vg's 
"stored" -- file formats -- renderer). This is the reason why I eventually need 
to make an incompatible Xmlm 2.0.0 rewritten on top of uutf.

A simple example showing usage of `Manual sources in uutf with Unix.read can be 
found here [4] (the second function, lines_fd). It should convince you that 
this is what you want.

Best,

Daniel

[1] https://github.com/dbuenzli/nbcodec/blob/master/RATIONALE
[2] http://erratique.ch/software/uutf
[3] http://erratique.ch/software/jsonm
[4] http://erratique.ch/software/uutf/doc/Uutf#readlines  




 


Rackspace

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