@@ -4164,11 +4164,12 @@ following table:
41644164
41654165 <dt><code> await <var ignore> writer</var> .{{WritableStreamDefaultWriter/ready}} </code>
41664166 <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.
41724173
41734174 <p> If the stream becomes errored or aborted, or the writer's lock is [=release a write
41744175 lock|released=] , the returned promise will become rejected.
@@ -4294,6 +4295,7 @@ The Web IDL definition for the {{WritableStreamDefaultController}} class is give
42944295interface WritableStreamDefaultController {
42954296 readonly attribute AbortSignal signal;
42964297 undefined error(optional any e);
4298+ undefined releaseBackpressure();
42974299};
42984300</xmp>
42994301
@@ -4323,6 +4325,10 @@ the following table:
43234325 <td> <dfn>\[[queueTotalSize]]</dfn>
43244326 <td class="non-normative"> The total size of all the chunks stored in
43254327 [=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
43264332 <tr>
43274333 <td> <dfn>\[[signal]]</dfn>
43284334 <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.
43694375 the [=underlying sink=] 's methods. However, it can be useful for suddenly shutting down a stream
43704376 in response to an event outside the normal lifecycle of interactions with the [=underlying
43714377 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.
43724389</dl>
43734390
43744391<div algorithm>
@@ -4387,6 +4404,15 @@ closed. It is only used internally, and is never exposed to web developers.
43874404 1. Perform ! [$WritableStreamDefaultControllerError$] ([=this=] , |e|).
43884405</div>
43894406
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+
43904416<h4 id="ws-default-controller-internal-methods">Internal methods</h4>
43914417
43924418The following are internal methods implemented by each {{WritableStreamDefaultController}} instance.
@@ -4951,6 +4977,7 @@ The following abstract operations support the implementation of the
49514977 1. Set |controller|.[=WritableStreamDefaultController/[[stream]]=] to |stream|.
49524978 1. Set |stream|.[=WritableStream/[[controller]]=] to |controller|.
49534979 1. Perform ! [$ResetQueue$] (|controller|).
4980+ 1. Set |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] to false.
49544981 1. Set |controller|.[=WritableStreamDefaultController/[[signal]]=] to a new {{AbortSignal}} .
49554982 1. Set |controller|.[=WritableStreamDefaultController/[[started]]=] to false.
49564983 1. Set |controller|.[=WritableStreamDefaultController/[[strategySizeAlgorithm]]=] to
@@ -5082,6 +5109,8 @@ The following abstract operations support the implementation of the
50825109 id="writable-stream-default-controller-get-backpressure"> WritableStreamDefaultControllerGetBackpressure(|controller|)</dfn>
50835110 performs the following steps:
50845111
5112+ 1. If |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] is true and
5113+ |controller|.[=WritableStreamDefaultController/[[queue]]=] [=list/is empty=] , return false.
50855114 1. Let |desiredSize| be ! [$WritableStreamDefaultControllerGetDesiredSize$] (|controller|).
50865115 1. Return true if |desiredSize| ≤ 0, or false otherwise.
50875116</div>
@@ -5152,6 +5181,20 @@ The following abstract operations support the implementation of the
51525181 1. Perform ! [$WritableStreamFinishInFlightWriteWithError$] (|stream|, |reason|).
51535182</div>
51545183
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+
51555198<div algorithm>
51565199 <dfn abstract-op lt="WritableStreamDefaultControllerWrite"
51575200 id="writable-stream-default-controller-write"> WritableStreamDefaultControllerWrite(|controller|,
@@ -5162,6 +5205,7 @@ The following abstract operations support the implementation of the
51625205 1. Perform ! [$WritableStreamDefaultControllerErrorIfNeeded$] (|controller|,
51635206 |enqueueResult|.\[[Value]] ).
51645207 1. Return.
5208+ 1. Set |controller|.[=WritableStreamDefaultController/[[releaseBackpressure]]=] to false.
51655209 1. Let |stream| be |controller|.[=WritableStreamDefaultController/[[stream]]=] .
51665210 1. If ! [$WritableStreamCloseQueuedOrInFlight$] (|stream|) is false and
51675211 |stream|.[=WritableStream/[[state]]=] is "`writable`",
@@ -5674,6 +5718,9 @@ The following abstract operations operate on {{TransformStream}} instances at a
56745718 stream.[=TransformStream/[[backpressureChangePromise]]=] with undefined.
56755719 1. Set |stream|.[=TransformStream/[[backpressureChangePromise]]=] to [=a new promise=] .
56765720 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]]=] ).
56775724</div>
56785725
56795726<h4 id="ts-default-controller-abstract-ops">Default controllers</h4>
0 commit comments