@@ -4161,11 +4161,12 @@ following table:
4161
4161
4162
4162
<dt><code> await <var ignore> writer</var> .{{WritableStreamDefaultWriter/ready}} </code>
4163
4163
<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.
4169
4170
4170
4171
<p> If the stream becomes errored or aborted, or the writer's lock is [=release a write
4171
4172
lock|released=] , the returned promise will become rejected.
@@ -4291,6 +4292,7 @@ The Web IDL definition for the {{WritableStreamDefaultController}} class is give
4291
4292
interface WritableStreamDefaultController {
4292
4293
readonly attribute AbortSignal signal;
4293
4294
undefined error(optional any e);
4295
+ undefined releaseBackpressure();
4294
4296
};
4295
4297
</xmp>
4296
4298
@@ -4320,6 +4322,10 @@ the following table:
4320
4322
<td> <dfn>\[[queueTotalSize]]</dfn>
4321
4323
<td class="non-normative"> The total size of all the chunks stored in
4322
4324
[=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
4323
4329
<tr>
4324
4330
<td> <dfn>\[[signal]]</dfn>
4325
4331
<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.
4366
4372
the [=underlying sink=] 's methods. However, it can be useful for suddenly shutting down a stream
4367
4373
in response to an event outside the normal lifecycle of interactions with the [=underlying
4368
4374
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.
4369
4386
</dl>
4370
4387
4371
4388
<div algorithm>
@@ -4384,6 +4401,15 @@ closed. It is only used internally, and is never exposed to web developers.
4384
4401
1. Perform ! [$WritableStreamDefaultControllerError$] ([=this=] , |e|).
4385
4402
</div>
4386
4403
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
+
4387
4413
<h4 id="ws-default-controller-internal-methods">Internal methods</h4>
4388
4414
4389
4415
The following are internal methods implemented by each {{WritableStreamDefaultController}} instance.
@@ -4948,6 +4974,7 @@ The following abstract operations support the implementation of the
4948
4974
1. Set |controller|.[=WritableStreamDefaultController/[[stream]]=] to |stream|.
4949
4975
1. Set |stream|.[=WritableStream/[[controller]]=] to |controller|.
4950
4976
1. Perform ! [$ResetQueue$] (|controller|).
4977
+ 1. Set |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] to false.
4951
4978
1. Set |controller|.[=WritableStreamDefaultController/[[signal]]=] to a new {{AbortSignal}} .
4952
4979
1. Set |controller|.[=WritableStreamDefaultController/[[started]]=] to false.
4953
4980
1. Set |controller|.[=WritableStreamDefaultController/[[strategySizeAlgorithm]]=] to
@@ -5079,6 +5106,8 @@ The following abstract operations support the implementation of the
5079
5106
id="writable-stream-default-controller-get-backpressure"> WritableStreamDefaultControllerGetBackpressure(|controller|)</dfn>
5080
5107
performs the following steps:
5081
5108
5109
+ 1. If |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] is true and
5110
+ |controller|.[=WritableStreamDefaultController/[[queue]]=] [=list/is empty=] , return false.
5082
5111
1. Let |desiredSize| be ! [$WritableStreamDefaultControllerGetDesiredSize$] (|controller|).
5083
5112
1. Return true if |desiredSize| ≤ 0, or false otherwise.
5084
5113
</div>
@@ -5149,6 +5178,20 @@ The following abstract operations support the implementation of the
5149
5178
1. Perform ! [$WritableStreamFinishInFlightWriteWithError$] (|stream|, |reason|).
5150
5179
</div>
5151
5180
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
+
5152
5195
<div algorithm>
5153
5196
<dfn abstract-op lt="WritableStreamDefaultControllerWrite"
5154
5197
id="writable-stream-default-controller-write"> WritableStreamDefaultControllerWrite(|controller|,
@@ -5159,6 +5202,7 @@ The following abstract operations support the implementation of the
5159
5202
1. Perform ! [$WritableStreamDefaultControllerErrorIfNeeded$] (|controller|,
5160
5203
|enqueueResult|.\[[Value]] ).
5161
5204
1. Return.
5205
+ 1. Set |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] to false.
5162
5206
1. Let |stream| be |controller|.[=WritableStreamDefaultController/[[stream]]=] .
5163
5207
1. If ! [$WritableStreamCloseQueuedOrInFlight$] (|stream|) is false and
5164
5208
|stream|.[=WritableStream/[[state]]=] is "`writable`",
@@ -5671,6 +5715,9 @@ The following abstract operations operate on {{TransformStream}} instances at a
5671
5715
stream.[=TransformStream/[[backpressureChangePromise]]=] with undefined.
5672
5716
1. Set |stream|.[=TransformStream/[[backpressureChangePromise]]=] to [=a new promise=] .
5673
5717
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]]=] ).
5674
5721
</div>
5675
5722
5676
5723
<h4 id="ts-default-controller-abstract-ops">Default controllers</h4>
0 commit comments