iopipe: Writing output to std.io File

Steven Schveighoffer schveiguy at gmail.com
Fri Jan 31 15:30:27 UTC 2020


On 1/30/20 12:59 AM, Jesse Phillips wrote:
> On Tuesday, 28 January 2020 at 16:09:55 UTC, Steven Schveighoffer wrote:
>>
>> Everything is pulled with iopipe, even output, so it's just a matter 
>> of who is pulling and when. Pushing is a matter of telling the other 
>> end to pull.
>>
> 
> That statement I think will be very helpful to me.
> 
> The push would control the buffer, creating that value concept, where 
> the buffer is flush which creates a pull, specified in the delegate.

The push function divides the buffer into 2 parts, the "writeable" items 
(i.e. items ready to push), and the buffer that can be accessed for 
manipulation (this is where you put your data). Eventually, the latter 
fills up and you need more buffer space. At this point, it performs the 
push, which is done by running the push chain as if it were an input 
stream, where the data source is the writeable data.

> 
> Pusher(buffer) <- put(content)
> 
> An output range wrapper would provide a push interface which would fill 
> in the buffer of the Pusher. When the buffer fills the range wrapper 
> would ask to release which Pusher does by calling the delegate.

An output range wrapper should fill in the accessible buffer and then 
immediately release it (same as that writeln example I showed before).

> Hopefully I'm following this correctly.

I was going to write an ascii art concept to show how the pushing works, 
but I think I'll maybe draw an actual picture. I need some time to 
accomplish this, though.

It's very clear in my head how this works, but very hard to describe :)

-Steve


More information about the Digitalmars-d-learn mailing list