Commit Graph

11 Commits (cfacde3ac6094281d77b19d846bfe3c57c28582f)

Author SHA1 Message Date
isaacs e03bc472f0 stream: Start out in sync=true state
The Readable and Writable classes will nextTick certain things
if in sync mode.  The sync flag gets unset after a call to _read
or _write.  However, most of these behaviors should also be
deferred until nextTick if no reads have been made (for example,
the automatic '_read up to hwm' behavior on Readable.push(chunk))

Set the sync flag to true in the constructor, so that it will not
trigger an immediate 'readable' event, call to _read, before the
user has had a chance to set a _read method implementation.
2013-02-25 07:38:10 -08:00
isaacs 3b2e9d2648 stream: remove lowWaterMark feature
It seems like a good idea on the face of it, but lowWaterMarks are
actually not useful, and in practice should always be set to zero.

It would be worthwhile for writers if we actually did some kind of
writev() type of thing, but actually this just delays calling write()
and the overhead of doing a bunch of Buffer copies is not worth the
slight benefit of calling write() fewer times.
2013-02-21 15:23:18 -08:00
isaacs e26622bd18 stream: Correct Transform class backpressure
The refactor in b43e544140 to use
stream.push() in Transform inadvertently caused it to immediately
consume all the written data, regardless of whether or not the readable
side was being consumed.

Only pull data through the _transform() process when the readable side
is being consumed.

Fix #4667
2013-01-28 08:40:45 -08:00
isaacs b43e544140 stream: Use push() for Transform._output()
This also slightly changes the semantics, in that a 'readable'
event may be triggered by the first write() call, even if a
user has not yet called read().

This happens because the Transform _write() handler is calling
read(0) to start the flow of data.  Technically, the new behavior
is more 'correct', since it is more in line with the semantics
of the 'readable' event in other streams.
2013-01-10 13:49:54 -08:00
isaacs b15e19a232 streams2: Remove function.bind() usage
It's too slow, unfortunately.
2012-12-13 17:00:32 -08:00
isaacs f20fd22abd streams2: Add high water mark for Readable
Also, organize the numeric settings a bit on the ReadableState class
2012-12-13 17:00:30 -08:00
isaacs 545f512619 streams2: ctor guards on Stream classes 2012-12-13 17:00:26 -08:00
isaacs 8acb416ad0 streams2: Handle immediate synthetic transforms properly 2012-12-13 17:00:26 -08:00
isaacs caa853bb06 transform: Automatically read() on _write when read buffer is empty 2012-12-13 17:00:25 -08:00
isaacs 3b59fd70f4 streams2: Make Transform streams pull-style
That is, the transform is triggered by a _read, not by a _write.

This way, backpressure works properly.
2012-12-13 17:00:24 -08:00
isaacs 420e07c577 streams2: The new stream base classes 2012-12-13 17:00:23 -08:00