Hello all,
not sure if I am the only one who finds the wordings on the Streams docs
(http://nodejs.org/api/stream.html)
a bit confusing for write().
The docs say for writable.write():
> Returns true if the data has been flushed to the underlying resource.
> Returns false to indicate that the buffer is full, and the data will be sent
> out in the future. The 'drain' event will indicate when the buffer is empty
> again.
The part “data will be sent out in the future” suggests that Node/Streams is
holding the data and will send it out. Along with the description that “true”
indicates flush to underlying resource, it gives the impression that there is
no action needed. But if the "buffer is full” then where is the data being
held? One hopes somewhere else. But then moving on to the ‘drain’ event:
> Emitted when the stream's write queue empties and it's safe to write without
> buffering again. Listen for it whenstream.write() returns false.
The text here gives the impression that the “buffer” being spoken of is a user
maintained buffer.
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.
Regards,
—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.