Skip to content

Commit fc0cb9d

Browse files
Update spec text
1 parent cf30f6e commit fc0cb9d

File tree

2 files changed

+53
-6
lines changed

2 files changed

+53
-6
lines changed

index.bs

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4295,11 +4295,12 @@ following table:
42954295

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

43044305
<p>If the stream becomes errored or aborted, or the writer's lock is [=release a write
43054306
lock|released=], the returned promise will become rejected.
@@ -4425,6 +4426,7 @@ The Web IDL definition for the {{WritableStreamDefaultController}} class is give
44254426
interface WritableStreamDefaultController {
44264427
readonly attribute AbortSignal signal;
44274428
undefined error(optional any e);
4429+
undefined releaseBackpressure();
44284430
};
44294431
</xmp>
44304432

@@ -4454,6 +4456,10 @@ the following table:
44544456
<td><dfn>\[[queueTotalSize]]</dfn>
44554457
<td class="non-normative">The total size of all the chunks stored in
44564458
[=WritableStreamDefaultController/[[queue]]=] (see [[#queue-with-sizes]])
4459+
<tr>
4460+
<td><dfn>\[[releaseBackpressure]]</dfn>
4461+
<td class="non-normative">A boolean flag indicating whether to release backpressure until the
4462+
next chunk is written
44574463
<tr>
44584464
<td><dfn>\[[signal]]</dfn>
44594465
<td class="non-normative">An {{AbortSignal}} that can be used to abort the pending write or
@@ -4500,6 +4506,17 @@ closed. It is only used internally, and is never exposed to web developers.
45004506
the [=underlying sink=]'s methods. However, it can be useful for suddenly shutting down a stream
45014507
in response to an event outside the normal lifecycle of interactions with the [=underlying
45024508
sink=].
4509+
<dt><code><var ignore>controller</var>.{{WritableStreamDefaultController/releaseBackpressure()|releaseBackpressure}}()</code>
4510+
<dd>
4511+
<p>Releases [=backpressure=] until the next chunk is written. If there are still chunks in the queue,
4512+
this does nothing.
4513+
4514+
<p>Usually, backpressure is automatically released when the [=desired size to fill a stream's
4515+
internal queue|desired size to fill the stream's internal queue=] becomes positive. However,
4516+
if the stream is created with a [=high water mark=] of zero, then the desired size is always at or
4517+
below zero, and the stream would always apply backpressure.
4518+
This method allows the [=underlying sink=] to manually release backpressure, for example when it
4519+
knows that now is a good time for the [=producer=] to write a new chunk.
45034520
</dl>
45044521

45054522
<div algorithm>
@@ -4518,6 +4535,15 @@ closed. It is only used internally, and is never exposed to web developers.
45184535
1. Perform ! [$WritableStreamDefaultControllerError$]([=this=], |e|).
45194536
</div>
45204537

4538+
<div algorithm>
4539+
The <dfn id="ws-default-controller-release-backpressure" method
4540+
for="WritableStreamDefaultController">releaseBackpressure()</dfn> method steps are:
4541+
4542+
1. Let |state| be [=this=].[=WritableStreamDefaultController/[[stream]]=].[=WritableStream/[[state]]=].
4543+
1. If |state| is not "`writable`", return.
4544+
1. Perform ! [$WritableStreamDefaultControllerReleaseBackpressure$]([=this=]).
4545+
</div>
4546+
45214547
<h4 id="ws-default-controller-internal-methods">Internal methods</h4>
45224548

45234549
The following are internal methods implemented by each {{WritableStreamDefaultController}} instance.
@@ -5082,6 +5108,7 @@ The following abstract operations support the implementation of the
50825108
1. Set |controller|.[=WritableStreamDefaultController/[[stream]]=] to |stream|.
50835109
1. Set |stream|.[=WritableStream/[[controller]]=] to |controller|.
50845110
1. Perform ! [$ResetQueue$](|controller|).
5111+
1. Set |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] to false.
50855112
1. Set |controller|.[=WritableStreamDefaultController/[[signal]]=] to a new {{AbortSignal}}.
50865113
1. Set |controller|.[=WritableStreamDefaultController/[[started]]=] to false.
50875114
1. Set |controller|.[=WritableStreamDefaultController/[[strategySizeAlgorithm]]=] to
@@ -5213,6 +5240,8 @@ The following abstract operations support the implementation of the
52135240
id="writable-stream-default-controller-get-backpressure">WritableStreamDefaultControllerGetBackpressure(|controller|)</dfn>
52145241
performs the following steps:
52155242

5243+
1. If |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] is true and
5244+
|controller|.[=WritableStreamDefaultController/[[queue]]=] [=list/is empty=], return false.
52165245
1. Let |desiredSize| be ! [$WritableStreamDefaultControllerGetDesiredSize$](|controller|).
52175246
1. Return true if |desiredSize| ≤ 0, or false otherwise.
52185247
</div>
@@ -5283,6 +5312,20 @@ The following abstract operations support the implementation of the
52835312
1. Perform ! [$WritableStreamFinishInFlightWriteWithError$](|stream|, |reason|).
52845313
</div>
52855314

5315+
<div algorithm>
5316+
<dfn abstract-op lt="WritableStreamDefaultControllerReleaseBackpressure"
5317+
id="writable-stream-default-controller-release-backpressure">WritableStreamDefaultControllerReleaseBackpressure(|controller|)</dfn>
5318+
performs the following steps:
5319+
5320+
1. Let |stream| be |controller|.[=WritableStreamDefaultController/[[stream]]=].
5321+
1. Assert: |stream|.[=WritableStream/[[state]]=] is "`writable`".
5322+
1. Set |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] to true.
5323+
1. If ! [$WritableStreamHasOperationMarkedInFlight$](|stream|) is false and
5324+
[$WritableStreamCloseQueuedOrInFlight$](|stream|) is false,
5325+
1. Let |backpressure| be ! [$WritableStreamDefaultControllerGetBackpressure$](|controller|).
5326+
1. Perform ! [$WritableStreamUpdateBackpressure$](|stream|, |backpressure|).
5327+
</div>
5328+
52865329
<div algorithm>
52875330
<dfn abstract-op lt="WritableStreamDefaultControllerWrite"
52885331
id="writable-stream-default-controller-write">WritableStreamDefaultControllerWrite(|controller|,
@@ -5293,6 +5336,7 @@ The following abstract operations support the implementation of the
52935336
1. Perform ! [$WritableStreamDefaultControllerErrorIfNeeded$](|controller|,
52945337
|enqueueResult|.\[[Value]]).
52955338
1. Return.
5339+
1. Set |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] to false.
52965340
1. Let |stream| be |controller|.[=WritableStreamDefaultController/[[stream]]=].
52975341
1. If ! [$WritableStreamCloseQueuedOrInFlight$](|stream|) is false and
52985342
|stream|.[=WritableStream/[[state]]=] is "`writable`",
@@ -5805,6 +5849,9 @@ The following abstract operations operate on {{TransformStream}} instances at a
58055849
stream.[=TransformStream/[[backpressureChangePromise]]=] with undefined.
58065850
1. Set |stream|.[=TransformStream/[[backpressureChangePromise]]=] to [=a new promise=].
58075851
1. Set |stream|.[=TransformStream/[[backpressure]]=] to |backpressure|.
5852+
1. If |backpressure| is false and |stream|.[=TransformStream/[[writable]]=].[=WritableStream/[[state]]=]
5853+
is "`writable`", perform !
5854+
[$WritableStreamDefaultControllerReleaseBackpressure$](|stream|.[=TransformStream/[[writable]]=].[=WritableStream/[[controller]]=]).
58085855
</div>
58095856

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

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

Lines changed: 1 addition & 1 deletion
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)