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 23790 - Remove size argument from read() and introduce pullAmount attribute instead
Summary: Remove size argument from read() and introduce pullAmount attribute instead
Status: RESOLVED FIXED
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-11 08:06 UTC by Takeshi Yoshino
Modified: 2013-12-05 19:56 UTC (History)
2 users (show)

See Also:


Attachments

Description Takeshi Yoshino 2013-11-11 08:06:54 UTC
Now readExact() and read() are separate. It looks we should do further refactoring to remove size (actually meant maxSize) argument from read() and introduce pullAmount attribute instead.

NOTE: This name (pullAmount) is chosen rather than "bufferSize" since it can have misleading message that we can control implementation detail of the producer.

We supposed that most people don't want to manually control pull amount but just want to use default value. So, the pulling amount parameter should be provided as an attribute.
Comment 1 Takeshi Yoshino 2013-11-11 19:20:06 UTC
Since we cannot install a hook which is invoked right after fulfill callback is run, a user cannot decrease pullAmount on completion of one read().

pullAmount = 1024
...
readPromise is fulfilled with 512 bytes
Fulfill callback is run asynchronously
Inside fulfill callback we run this
  pullAmount = 512
But at this point, underlying IO may be already instructed to fetch 1024 bytes of data.

We should enable gradual decrease of pullAmount?
Comment 2 Takeshi Yoshino 2013-11-11 19:41:30 UTC
(In reply to Takeshi Yoshino from comment #1)
> Since we cannot install a hook which is invoked right after fulfill callback
> is run, a user cannot decrease pullAmount on completion of one read().
> 
> pullAmount = 1024
> ...
> readPromise is fulfilled with 512 bytes
> Fulfill callback is run asynchronously
> Inside fulfill callback we run this
>   pullAmount = 512
> But at this point, underlying IO may be already instructed to fetch 1024
> bytes of data.
> 
> We should enable gradual decrease of pullAmount?

Until next read() call, the number of bytes used for fulfilling the last read() call should occupy the pullAmount.
Comment 3 Takeshi Yoshino 2013-11-13 17:13:51 UTC
(In reply to Takeshi Yoshino from comment #2)
> Until next read() call, the number of bytes used for fulfilling the last
> read() call should occupy the pullAmount.

Done in preview ver. bytesBeingOutpu does it.
https://dvcs.w3.org/hg/streams-api/raw-file/tip/preview.html
Comment 4 Takeshi Yoshino 2013-11-14 01:51:34 UTC
Should pullAmount reset bytesBeingOutput?
Comment 5 Takeshi Yoshino 2013-12-05 19:56:34 UTC
Preview ver merged into ED. Closing this bug.

(In reply to Takeshi Yoshino from comment #4)
> Should pullAmount reset bytesBeingOutput?

This is put into a separate bug entry.
https://www.w3.org/Bugs/Public/show_bug.cgi?id=24008