This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 23736 - Add fork() method instead of having pipe(Stream[]) overload
Summary: Add fork() method instead of having pipe(Stream[]) overload
Status: NEW
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: Streams API (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Takeshi Yoshino
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-06 06:57 UTC by Takeshi Yoshino
Modified: 2013-11-07 21:15 UTC (History)
2 users (show)

See Also:


Attachments

Description Takeshi Yoshino 2013-11-06 06:57:33 UTC
There're requests to make it able to mirror a byte stream to multiple destinations. Currently, it's addressed by pipe(Stream[]) but it involves memory copy.

Rather than that, we could choose to make ReadableByteStream clonable.

fork() creates another ReadableByteStream instance that refers to the same internal data source as the original ReadableByteStream. Implementation of the original ReadableByteStream may choose to have range reference counting to control lifetime of the original data source sequence.

Each ReadableByteStream works like "reading cursors" for the original data source.

Since the internal data source sequence is not drained until all the cursors are done, a slow consumer can block fast ones.

If you don't want to block the faster consumers, you can choose to insert a ByteStream to buffer data for the slow consumer while keep draining data from the original data source quickly.

----

We haven't done enough study about necessity of pipe().

pull/push strategy of pipe() should also be well researched.
Comment 1 Takeshi Yoshino 2013-11-06 12:08:20 UTC
Check out ServiceWorker's use case.
https://github.com/slightlyoff/ServiceWorker
Comment 2 Takeshi Yoshino 2013-11-07 16:43:04 UTC
Added a section describing decoupling of data source and ReadableByteStream.

https://dvcs.w3.org/hg/streams-api/raw-file/tip/preview.html

This would help implementing substream() method.
Comment 3 Takeshi Yoshino 2013-11-07 18:13:00 UTC
We can start with fork() feature without size. (we call fork() with size as "substream()"). When there's request for substream(), let's add.
Comment 4 Takeshi Yoshino 2013-11-07 21:15:22 UTC
fork() done in preview ver https://dvcs.w3.org/hg/streams-api/raw-file/tip/preview.html

Strategy option (explained in the first post) not done.