@@ -4295,11 +4295,12 @@ following table:
4295
4295
4296
4296
<dt><code> await <var ignore> writer</var> .{{WritableStreamDefaultWriter/ready}} </code>
4297
4297
<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.
4303
4304
4304
4305
<p> If the stream becomes errored or aborted, or the writer's lock is [=release a write
4305
4306
lock|released=] , the returned promise will become rejected.
@@ -4425,6 +4426,7 @@ The Web IDL definition for the {{WritableStreamDefaultController}} class is give
4425
4426
interface WritableStreamDefaultController {
4426
4427
readonly attribute AbortSignal signal;
4427
4428
undefined error(optional any e);
4429
+ undefined releaseBackpressure();
4428
4430
};
4429
4431
</xmp>
4430
4432
@@ -4454,6 +4456,10 @@ the following table:
4454
4456
<td> <dfn>\[[queueTotalSize]]</dfn>
4455
4457
<td class="non-normative"> The total size of all the chunks stored in
4456
4458
[=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
4457
4463
<tr>
4458
4464
<td> <dfn>\[[signal]]</dfn>
4459
4465
<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.
4500
4506
the [=underlying sink=] 's methods. However, it can be useful for suddenly shutting down a stream
4501
4507
in response to an event outside the normal lifecycle of interactions with the [=underlying
4502
4508
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.
4503
4520
</dl>
4504
4521
4505
4522
<div algorithm>
@@ -4518,6 +4535,15 @@ closed. It is only used internally, and is never exposed to web developers.
4518
4535
1. Perform ! [$WritableStreamDefaultControllerError$] ([=this=] , |e|).
4519
4536
</div>
4520
4537
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
+
4521
4547
<h4 id="ws-default-controller-internal-methods">Internal methods</h4>
4522
4548
4523
4549
The following are internal methods implemented by each {{WritableStreamDefaultController}} instance.
@@ -5082,6 +5108,7 @@ The following abstract operations support the implementation of the
5082
5108
1. Set |controller|.[=WritableStreamDefaultController/[[stream]]=] to |stream|.
5083
5109
1. Set |stream|.[=WritableStream/[[controller]]=] to |controller|.
5084
5110
1. Perform ! [$ResetQueue$] (|controller|).
5111
+ 1. Set |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] to false.
5085
5112
1. Set |controller|.[=WritableStreamDefaultController/[[signal]]=] to a new {{AbortSignal}} .
5086
5113
1. Set |controller|.[=WritableStreamDefaultController/[[started]]=] to false.
5087
5114
1. Set |controller|.[=WritableStreamDefaultController/[[strategySizeAlgorithm]]=] to
@@ -5213,6 +5240,8 @@ The following abstract operations support the implementation of the
5213
5240
id="writable-stream-default-controller-get-backpressure"> WritableStreamDefaultControllerGetBackpressure(|controller|)</dfn>
5214
5241
performs the following steps:
5215
5242
5243
+ 1. If |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] is true and
5244
+ |controller|.[=WritableStreamDefaultController/[[queue]]=] [=list/is empty=] , return false.
5216
5245
1. Let |desiredSize| be ! [$WritableStreamDefaultControllerGetDesiredSize$] (|controller|).
5217
5246
1. Return true if |desiredSize| ≤ 0, or false otherwise.
5218
5247
</div>
@@ -5283,6 +5312,20 @@ The following abstract operations support the implementation of the
5283
5312
1. Perform ! [$WritableStreamFinishInFlightWriteWithError$] (|stream|, |reason|).
5284
5313
</div>
5285
5314
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
+
5286
5329
<div algorithm>
5287
5330
<dfn abstract-op lt="WritableStreamDefaultControllerWrite"
5288
5331
id="writable-stream-default-controller-write"> WritableStreamDefaultControllerWrite(|controller|,
@@ -5293,6 +5336,7 @@ The following abstract operations support the implementation of the
5293
5336
1. Perform ! [$WritableStreamDefaultControllerErrorIfNeeded$] (|controller|,
5294
5337
|enqueueResult|.\[[Value]] ).
5295
5338
1. Return.
5339
+ 1. Set |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] to false.
5296
5340
1. Let |stream| be |controller|.[=WritableStreamDefaultController/[[stream]]=] .
5297
5341
1. If ! [$WritableStreamCloseQueuedOrInFlight$] (|stream|) is false and
5298
5342
|stream|.[=WritableStream/[[state]]=] is "`writable`",
@@ -5805,6 +5849,9 @@ The following abstract operations operate on {{TransformStream}} instances at a
5805
5849
stream.[=TransformStream/[[backpressureChangePromise]]=] with undefined.
5806
5850
1. Set |stream|.[=TransformStream/[[backpressureChangePromise]]=] to [=a new promise=] .
5807
5851
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]]=] ).
5808
5855
</div>
5809
5856
5810
5857
<h4 id="ts-default-controller-abstract-ops">Default controllers</h4>
0 commit comments