stream interfaces - with ranges

Steven Schveighoffer schveiguy at yahoo.com
Fri May 18 10:51:50 PDT 2012


On Fri, 18 May 2012 13:27:22 -0400, kenji hara <k.hara.pg at gmail.com> wrote:

> 2012/5/19 Steven Schveighoffer <schveiguy at yahoo.com>:
>> On Fri, 18 May 2012 10:39:55 -0400, kenji hara <k.hara.pg at gmail.com>  
>> wrote:
>>>>> I'm designing experimental IO primitives:
>>>>> https://github.com/9rnsr/dio
>>
>> I'm having trouble following the code, is there a place with the  
>> generated
>> docs?   I'm looking for an overview to understand where to look.
>
> I have created gh-pages:
> http://9rnsr.github.com/dio/d/io_core.html

OK, *now* I understand what you mean by non-blocking.  There are some I/O  
packages that use asynchronous i/o which return even before any data is  
given to the buffer.  I thought this is what you were talking about.

I'm fully on board with synchronous but non-blocking.  That's what I  
assumed we would be doing, and it's well supported by low-level OS  
routines on all OSes.

In my implementation for a buffer, I have two calls:

read(buf[]) -> read until buf.length bytes are read or EOF
readPartial(buf[]) -> read from 1 to buf.length bytes, but performs at  
most 1 low-level read.  Returns 0 bytes on EOF.

readPartial will block if no data is yet available, but obviously can be  
made to not block if the underlying OS handle is marked as non-blocking (I  
need to add some extra structure to account for this).

Typically, this is the normal mechanism that I use for reading data that  
is not always available.  First, I select on a socket until data is  
available, then use synchronous read to get whatever data exists.

continuing reading...

-Steve


More information about the Digitalmars-d mailing list