- From: Scott Haseley <notifications@github.com>
- Date: Tue, 16 May 2023 17:18:30 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/pull/1152/review/1429609384@github.com>
@shaseley commented on this pull request. > + <p>If <var>signal</var>'s [=AbortSignal/dependent=] is false, then: + + <ol> + <li><p><a for=set>Append</a> <var>signal</var> to <var>resultSignal</var>'s + [=AbortSignal/source signals=]. + + <li><p><a for=set>Append</a> <var>resultSignal</var> to <var>signal</var>'s + [=AbortSignal/dependent signals=]. + </ol> + + <li> + <p>Otherwise, <a for=list>for each</a> <var>sourceSignal</var> of <var>signal</var>'s + [=AbortSignal/source signals=]: + + <ol> + <li><p>Assert: <var>sourceSignal</var> is not [=AbortSignal/aborted=] and not It can be called with dependent signals. When it encounters one in the outer for-loop, it iterates over the dependent signal's source signals and links those. And by always linking to a dependent's source signals, dependent signals are never added as sources. So this is saying "a dependent signal's source signal cannot be a dependent signal." The idea is something like this: ```js const root = someController.signal; // Non-dependent signal passed, simple case (append it directly): // root.__dependent_signals = [signal1]; // signal1.__source_signals = [root]; const signal1 = AbortSignal.any([someController.signal]); // Dependent signal passed, iterate over its source signals and link those: // root.__dependent_signals = [signal1, signal2]; // signal2.__source_signals = [root]; (note: root is linked, not signal1). const signal2 = AbortSignal.any([signal1]); // Same as above: // root.__dependent_signals = [signal1, signal2, signal3]; // signal3.__source_signals = [root]; const signal3 = AbortSignal.any([signal2]); ``` This is by design to "flatten" the signal dependency graph by linking directly to signals that can abort directly (timeouts or controller signals), which helps optimize GC since intermediates aren't kept alive to propagate abort. (Note also that new sources are fixed at construction time). -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/pull/1152#discussion_r1195802133 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/pull/1152/review/1429609384@github.com>
Received on Wednesday, 17 May 2023 00:18:35 UTC