Skip to content

Commit b2b6c88

Browse files
Update spec text
1 parent 4fd1b3b commit b2b6c88

File tree

2 files changed

+53
-6
lines changed

2 files changed

+53
-6
lines changed

index.bs

+52-5
Original file line numberDiff line numberDiff line change
@@ -4161,11 +4161,12 @@ following table:
41614161

41624162
<dt><code>await <var ignore>writer</var>.{{WritableStreamDefaultWriter/ready}}</code>
41634163
<dd>
4164-
<p>Returns a promise that will be fulfilled when the [=desired size to fill a stream's internal
4165-
queue|desired size to fill the stream's internal queue=] transitions from non-positive to
4166-
positive, signaling that it is no longer applying [=backpressure=]. Once the [=desired size to
4167-
fill a stream's internal queue|desired size=] dips back to zero or below, the getter will return
4168-
a new promise that stays pending until the next transition.
4164+
<p>Returns a promise that will be fulfilled when either the [=desired size to fill a stream's
4165+
internal queue|desired size to fill the stream's internal queue=] transitions from non-positive to
4166+
positive or when the stream calls {{WritableStreamDefaultController/releaseBackpressure()}},
4167+
signaling that it is no longer applying [=backpressure=].
4168+
Once the [=desired size to fill a stream's internal queue|desired size=] dips back to zero or below,
4169+
the getter will return a new promise that stays pending until the next transition.
41694170

41704171
<p>If the stream becomes errored or aborted, or the writer's lock is [=release a write
41714172
lock|released=], the returned promise will become rejected.
@@ -4291,6 +4292,7 @@ The Web IDL definition for the {{WritableStreamDefaultController}} class is give
42914292
interface WritableStreamDefaultController {
42924293
readonly attribute AbortSignal signal;
42934294
undefined error(optional any e);
4295+
undefined releaseBackpressure();
42944296
};
42954297
</xmp>
42964298

@@ -4320,6 +4322,10 @@ the following table:
43204322
<td><dfn>\[[queueTotalSize]]</dfn>
43214323
<td class="non-normative">The total size of all the chunks stored in
43224324
[=WritableStreamDefaultController/[[queue]]=] (see [[#queue-with-sizes]])
4325+
<tr>
4326+
<td><dfn>\[[releaseBackpressure]]</dfn>
4327+
<td class="non-normative">A boolean flag indicating whether to release backpressure until the
4328+
next chunk is written
43234329
<tr>
43244330
<td><dfn>\[[signal]]</dfn>
43254331
<td class="non-normative">An {{AbortSignal}} that can be used to abort the pending write or
@@ -4366,6 +4372,17 @@ closed. It is only used internally, and is never exposed to web developers.
43664372
the [=underlying sink=]'s methods. However, it can be useful for suddenly shutting down a stream
43674373
in response to an event outside the normal lifecycle of interactions with the [=underlying
43684374
sink=].
4375+
<dt><code><var ignore>controller</var>.{{WritableStreamDefaultController/releaseBackpressure()|releaseBackpressure}}()</code>
4376+
<dd>
4377+
<p>Releases [=backpressure=] until the next chunk is written. If there are still chunks in the queue,
4378+
this does nothing.
4379+
4380+
<p>Usually, backpressure is automatically released when the [=desired size to fill a stream's
4381+
internal queue|desired size to fill the stream's internal queue=] becomes positive. However,
4382+
if the stream is created with a [=high water mark=] of zero, then the desired size is always at or
4383+
below zero, and the stream would always apply backpressure.
4384+
This method allows the [=underlying sink=] to manually release backpressure, for example when it
4385+
knows that now is a good time for the [=producer=] to write a new chunk.
43694386
</dl>
43704387

43714388
<div algorithm>
@@ -4384,6 +4401,15 @@ closed. It is only used internally, and is never exposed to web developers.
43844401
1. Perform ! [$WritableStreamDefaultControllerError$]([=this=], |e|).
43854402
</div>
43864403

4404+
<div algorithm>
4405+
The <dfn id="ws-default-controller-release-backpressure" method
4406+
for="WritableStreamDefaultController">releaseBackpressure()</dfn> method steps are:
4407+
4408+
1. Let |state| be [=this=].[=WritableStreamDefaultController/[[stream]]=].[=WritableStream/[[state]]=].
4409+
1. If |state| is not "`writable`", return.
4410+
1. Perform ! [$WritableStreamDefaultControllerReleaseBackpressure$]([=this=]).
4411+
</div>
4412+
43874413
<h4 id="ws-default-controller-internal-methods">Internal methods</h4>
43884414

43894415
The following are internal methods implemented by each {{WritableStreamDefaultController}} instance.
@@ -4948,6 +4974,7 @@ The following abstract operations support the implementation of the
49484974
1. Set |controller|.[=WritableStreamDefaultController/[[stream]]=] to |stream|.
49494975
1. Set |stream|.[=WritableStream/[[controller]]=] to |controller|.
49504976
1. Perform ! [$ResetQueue$](|controller|).
4977+
1. Set |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] to false.
49514978
1. Set |controller|.[=WritableStreamDefaultController/[[signal]]=] to a new {{AbortSignal}}.
49524979
1. Set |controller|.[=WritableStreamDefaultController/[[started]]=] to false.
49534980
1. Set |controller|.[=WritableStreamDefaultController/[[strategySizeAlgorithm]]=] to
@@ -5079,6 +5106,8 @@ The following abstract operations support the implementation of the
50795106
id="writable-stream-default-controller-get-backpressure">WritableStreamDefaultControllerGetBackpressure(|controller|)</dfn>
50805107
performs the following steps:
50815108

5109+
1. If |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] is true and
5110+
|controller|.[=WritableStreamDefaultController/[[queue]]=] [=list/is empty=], return false.
50825111
1. Let |desiredSize| be ! [$WritableStreamDefaultControllerGetDesiredSize$](|controller|).
50835112
1. Return true if |desiredSize| ≤ 0, or false otherwise.
50845113
</div>
@@ -5149,6 +5178,20 @@ The following abstract operations support the implementation of the
51495178
1. Perform ! [$WritableStreamFinishInFlightWriteWithError$](|stream|, |reason|).
51505179
</div>
51515180

5181+
<div algorithm>
5182+
<dfn abstract-op lt="WritableStreamDefaultControllerReleaseBackpressure"
5183+
id="writable-stream-default-controller-release-backpressure">WritableStreamDefaultControllerReleaseBackpressure(|controller|)</dfn>
5184+
performs the following steps:
5185+
5186+
1. Let |stream| be |controller|.[=WritableStreamDefaultController/[[stream]]=].
5187+
1. Assert: |stream|.[=WritableStream/[[state]]=] is "`writable`".
5188+
1. Set |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] to true.
5189+
1. If ! [$WritableStreamHasOperationMarkedInFlight$](|stream|) is false and
5190+
[$WritableStreamCloseQueuedOrInFlight$](|stream|) is false,
5191+
1. Let |backpressure| be ! [$WritableStreamDefaultControllerGetBackpressure$](|controller|).
5192+
1. Perform ! [$WritableStreamUpdateBackpressure$](|stream|, |backpressure|).
5193+
</div>
5194+
51525195
<div algorithm>
51535196
<dfn abstract-op lt="WritableStreamDefaultControllerWrite"
51545197
id="writable-stream-default-controller-write">WritableStreamDefaultControllerWrite(|controller|,
@@ -5159,6 +5202,7 @@ The following abstract operations support the implementation of the
51595202
1. Perform ! [$WritableStreamDefaultControllerErrorIfNeeded$](|controller|,
51605203
|enqueueResult|.\[[Value]]).
51615204
1. Return.
5205+
1. Set |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] to false.
51625206
1. Let |stream| be |controller|.[=WritableStreamDefaultController/[[stream]]=].
51635207
1. If ! [$WritableStreamCloseQueuedOrInFlight$](|stream|) is false and
51645208
|stream|.[=WritableStream/[[state]]=] is "`writable`",
@@ -5671,6 +5715,9 @@ The following abstract operations operate on {{TransformStream}} instances at a
56715715
stream.[=TransformStream/[[backpressureChangePromise]]=] with undefined.
56725716
1. Set |stream|.[=TransformStream/[[backpressureChangePromise]]=] to [=a new promise=].
56735717
1. Set |stream|.[=TransformStream/[[backpressure]]=] to |backpressure|.
5718+
1. If |backpressure| is false and |stream|.[=TransformStream/[[writable]]=].[=WritableStream/[[state]]=]
5719+
is "`writable`", perform !
5720+
[$WritableStreamDefaultControllerReleaseBackpressure$](|stream|.[=TransformStream/[[writable]]=].[=WritableStream/[[controller]]=]).
56745721
</div>
56755722

56765723
<h4 id="ts-default-controller-abstract-ops">Default controllers</h4>

reference-implementation/lib/abstract-ops/writable-streams.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,9 @@ function SetUpWritableStreamDefaultController(stream, controller, startAlgorithm
542542
controller._queueTotalSize = undefined;
543543
ResetQueue(controller);
544544

545+
controller._releaseBackpressure = false;
545546
controller._abortController = new AbortController();
546547
controller._started = false;
547-
controller._releaseBackpressure = false;
548548

549549
controller._strategySizeAlgorithm = sizeAlgorithm;
550550
controller._strategyHWM = highWaterMark;

0 commit comments

Comments
 (0)