On Jun 13, 2013, at 1:37 AM, mscdex <[email protected]> wrote:
> On Jun 12, 7:01 pm, // ravi <[email protected]> wrote:
> <snip happens>
> If you continue to write() after write() returns false but before
> 'drain' is emitted, the writes will be buffered in user memory (e.g.
> an array) because the kernel buffer is too full.
>
>> My question: what is the correct interpretation of this doc?
>>
>> (a) When writable.write() returns false, then the user should start
>> buffering up data until s/he receives a ‘drain’ event at which point writes
>> can be attempted again. It is the user’s responsibility to buffer on ‘false’
>> (including for the chunk for which write() returned false).
>>
>> (b) The Stream interface will take care of saving the write()s somewhere
>> even when it returns false and the “data will be sent out in the future”.
>> This requires no action from the user and there is really no need to listen
>> to ‘drain’ for this reason.
>>
>> I suspect (a) is the case, but figured I would ask.
>
> It's (b). Although you may care to listen for 'drain' if you don't
> want to keep using up more and more memory. It should be noted that
> when piping streams, all of the listening for 'drain' and such is
> handled for you.
>
Thank you “mscdex”. That (b) is the answer makes my life easier (as long as the
user space memory doesn’t blow up!).
Pipes was how I went in my first implementation but soon the fact that
on(‘data’) keeps emitting even if there’s nobody there yet to hear it, along
with the alleged unreliability of pause()/resume() in 0.8.x or earlier, gave me
the feeling (perhaps wrong) that I will need to buffer up data until my
writestream was ready (which in turn implied pipe wouldn’t be usable).
Cheers,
—ravi
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.