read_next_avail?

H

Tanaka Akira <akr / m17n.org> wrote in message news:<873c3jm2lz.fsf / serein.a02.aist.go.jp>...
> In article <gGSdnSk4oLg_DZ3cSa8jmA / karoo.co.uk>,
>   "daz" <dooby / d10.karoo.co.uk> writes:
> 
> > I thought Hal's read_avail (perhaps readavail) was a fair description, but ...
> >
> > "readpartial may return data which is not available when readpartial is called"
> >
> > Then 'readpartial' is magic ?-)  (Returns unavailable data)
> > I know ... I misunderstand :(
> 
> readpartial blocks in such case.
> 
> % (sleep 1; echo abc; sleep 1; echo def) | ./ruby -e 't1 = Time.now; p STDIN.readpartial(4096); t2 = Time.now; p t2-t1'
> "abc\n"
> 1.001787
> 
> In this case, readpartial blocks because there are no data at first.
> After 1 second, "abc" is sent over the pipe and readpartial reads and
> returns it.
> 
> So, the name read_avail is not accurate.
> 
> >  read_immed ?
> > (readimmed is *very bad* without the underscore -- weird ! )
> >
> >  read_direct ?  (probably not good)
> >
> >  read_instant, readinst, readsnap ?  (at this instant in time)
> 
> How about them, matz?
> 
> > I think the problem with the name 'readpartial' may be that if *all*
> > data is available, and 'readpartial' reads it all, then it has "failed"
> > because it has performed 'read', *not* 'readpartial'.   :->
> 
> Yes.
> 
> > 'readchunk' gives too much emphasis to the chunk, IMHO.
> >  readchunk(256) looks too predictable.
> > If I wanted to read from <ios> in chunks, I would try that before
> > reading the docs.
> 
> Also, several formats such as PNG defines "chunk" in their spec.