@@ -4164,11 +4164,12 @@ following table:
4164
4164
4165
4165
<dt><code> await <var ignore> writer</var> .{{WritableStreamDefaultWriter/ready}} </code>
4166
4166
<dd>
4167
- <p> Returns a promise that will be fulfilled when the [=desired size to fill a stream's internal
4168
- queue|desired size to fill the stream's internal queue=] transitions from non-positive to
4169
- positive, signaling that it is no longer applying [=backpressure=] . Once the [=desired size to
4170
- fill a stream's internal queue|desired size=] dips back to zero or below, the getter will return
4171
- a new promise that stays pending until the next transition.
4167
+ <p> Returns a promise that will be fulfilled when either the [=desired size to fill a stream's
4168
+ internal queue|desired size to fill the stream's internal queue=] transitions from non-positive to
4169
+ positive or when the stream calls {{WritableStreamDefaultController/releaseBackpressure()}} ,
4170
+ signaling that it is no longer applying [=backpressure=] .
4171
+ Once the [=desired size to fill a stream's internal queue|desired size=] dips back to zero or below,
4172
+ the getter will return a new promise that stays pending until the next transition.
4172
4173
4173
4174
<p> If the stream becomes errored or aborted, or the writer's lock is [=release a write
4174
4175
lock|released=] , the returned promise will become rejected.
@@ -4294,6 +4295,7 @@ The Web IDL definition for the {{WritableStreamDefaultController}} class is give
4294
4295
interface WritableStreamDefaultController {
4295
4296
readonly attribute AbortSignal signal;
4296
4297
undefined error(optional any e);
4298
+ undefined releaseBackpressure();
4297
4299
};
4298
4300
</xmp>
4299
4301
@@ -4323,6 +4325,10 @@ the following table:
4323
4325
<td> <dfn>\[[queueTotalSize]]</dfn>
4324
4326
<td class="non-normative"> The total size of all the chunks stored in
4325
4327
[=WritableStreamDefaultController/[[queue]]=] (see [[#queue-with-sizes]] )
4328
+ <tr>
4329
+ <td> <dfn>\[[releaseBackpressure]]</dfn>
4330
+ <td class="non-normative"> A boolean flag indicating whether to release backpressure until the
4331
+ next chunk is written
4326
4332
<tr>
4327
4333
<td> <dfn>\[[signal]]</dfn>
4328
4334
<td class="non-normative"> An {{AbortSignal}} that can be used to abort the pending write or
@@ -4369,6 +4375,17 @@ closed. It is only used internally, and is never exposed to web developers.
4369
4375
the [=underlying sink=] 's methods. However, it can be useful for suddenly shutting down a stream
4370
4376
in response to an event outside the normal lifecycle of interactions with the [=underlying
4371
4377
sink=] .
4378
+ <dt><code><var ignore> controller</var> .{{WritableStreamDefaultController/releaseBackpressure()|releaseBackpressure}} ()</code>
4379
+ <dd>
4380
+ <p> Releases [=backpressure=] until the next chunk is written. If there are still chunks in the queue,
4381
+ this does nothing.
4382
+
4383
+ <p> Usually, backpressure is automatically released when the [=desired size to fill a stream's
4384
+ internal queue|desired size to fill the stream's internal queue=] becomes positive. However,
4385
+ if the stream is created with a [=high water mark=] of zero, then the desired size is always at or
4386
+ below zero, and the stream would always apply backpressure.
4387
+ This method allows the [=underlying sink=] to manually release backpressure, for example when it
4388
+ knows that now is a good time for the [=producer=] to write a new chunk.
4372
4389
</dl>
4373
4390
4374
4391
<div algorithm>
@@ -4387,6 +4404,15 @@ closed. It is only used internally, and is never exposed to web developers.
4387
4404
1. Perform ! [$WritableStreamDefaultControllerError$] ([=this=] , |e|).
4388
4405
</div>
4389
4406
4407
+ <div algorithm>
4408
+ The <dfn id="ws-default-controller-release-backpressure" method
4409
+ for="WritableStreamDefaultController"> releaseBackpressure()</dfn> method steps are:
4410
+
4411
+ 1. Let |state| be [=this=] .[=WritableStreamDefaultController/[[stream]]=] .[=WritableStream/[[state]]=] .
4412
+ 1. If |state| is not "`writable`", return.
4413
+ 1. Perform ! [$WritableStreamDefaultControllerReleaseBackpressure$] ([=this=] ).
4414
+ </div>
4415
+
4390
4416
<h4 id="ws-default-controller-internal-methods">Internal methods</h4>
4391
4417
4392
4418
The following are internal methods implemented by each {{WritableStreamDefaultController}} instance.
@@ -4951,6 +4977,7 @@ The following abstract operations support the implementation of the
4951
4977
1. Set |controller|.[=WritableStreamDefaultController/[[stream]]=] to |stream|.
4952
4978
1. Set |stream|.[=WritableStream/[[controller]]=] to |controller|.
4953
4979
1. Perform ! [$ResetQueue$] (|controller|).
4980
+ 1. Set |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] to false.
4954
4981
1. Set |controller|.[=WritableStreamDefaultController/[[signal]]=] to a new {{AbortSignal}} .
4955
4982
1. Set |controller|.[=WritableStreamDefaultController/[[started]]=] to false.
4956
4983
1. Set |controller|.[=WritableStreamDefaultController/[[strategySizeAlgorithm]]=] to
@@ -5082,6 +5109,8 @@ The following abstract operations support the implementation of the
5082
5109
id="writable-stream-default-controller-get-backpressure"> WritableStreamDefaultControllerGetBackpressure(|controller|)</dfn>
5083
5110
performs the following steps:
5084
5111
5112
+ 1. If |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] is true and
5113
+ |controller|.[=WritableStreamDefaultController/[[queue]]=] [=list/is empty=] , return false.
5085
5114
1. Let |desiredSize| be ! [$WritableStreamDefaultControllerGetDesiredSize$] (|controller|).
5086
5115
1. Return true if |desiredSize| ≤ 0, or false otherwise.
5087
5116
</div>
@@ -5152,6 +5181,20 @@ The following abstract operations support the implementation of the
5152
5181
1. Perform ! [$WritableStreamFinishInFlightWriteWithError$] (|stream|, |reason|).
5153
5182
</div>
5154
5183
5184
+ <div algorithm>
5185
+ <dfn abstract-op lt="WritableStreamDefaultControllerReleaseBackpressure"
5186
+ id="writable-stream-default-controller-release-backpressure"> WritableStreamDefaultControllerReleaseBackpressure(|controller|)</dfn>
5187
+ performs the following steps:
5188
+
5189
+ 1. Let |stream| be |controller|.[=WritableStreamDefaultController/[[stream]]=] .
5190
+ 1. Assert: |stream|.[=WritableStream/[[state]]=] is "`writable`".
5191
+ 1. Set |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] to true.
5192
+ 1. If ! [$WritableStreamHasOperationMarkedInFlight$] (|stream|) is false and
5193
+ [$WritableStreamCloseQueuedOrInFlight$] (|stream|) is false,
5194
+ 1. Let |backpressure| be ! [$WritableStreamDefaultControllerGetBackpressure$] (|controller|).
5195
+ 1. Perform ! [$WritableStreamUpdateBackpressure$] (|stream|, |backpressure|).
5196
+ </div>
5197
+
5155
5198
<div algorithm>
5156
5199
<dfn abstract-op lt="WritableStreamDefaultControllerWrite"
5157
5200
id="writable-stream-default-controller-write"> WritableStreamDefaultControllerWrite(|controller|,
@@ -5162,6 +5205,7 @@ The following abstract operations support the implementation of the
5162
5205
1. Perform ! [$WritableStreamDefaultControllerErrorIfNeeded$] (|controller|,
5163
5206
|enqueueResult|.\[[Value]] ).
5164
5207
1. Return.
5208
+ 1. Set |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] to false.
5165
5209
1. Let |stream| be |controller|.[=WritableStreamDefaultController/[[stream]]=] .
5166
5210
1. If ! [$WritableStreamCloseQueuedOrInFlight$] (|stream|) is false and
5167
5211
|stream|.[=WritableStream/[[state]]=] is "`writable`",
@@ -5674,6 +5718,9 @@ The following abstract operations operate on {{TransformStream}} instances at a
5674
5718
stream.[=TransformStream/[[backpressureChangePromise]]=] with undefined.
5675
5719
1. Set |stream|.[=TransformStream/[[backpressureChangePromise]]=] to [=a new promise=] .
5676
5720
1. Set |stream|.[=TransformStream/[[backpressure]]=] to |backpressure|.
5721
+ 1. If |backpressure| is false and |stream|.[=TransformStream/[[writable]]=] .[=WritableStream/[[state]]=]
5722
+ is "`writable`", perform !
5723
+ [$WritableStreamDefaultControllerReleaseBackpressure$] (|stream|.[=TransformStream/[[writable]]=] .[=WritableStream/[[controller]]=] ).
5677
5724
</div>
5678
5725
5679
5726
<h4 id="ts-default-controller-abstract-ops">Default controllers</h4>
0 commit comments