Editorial: collapse "actively needed" and "protected" for workers #11598
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It turns out these concepts are identical, and it was just very hard to tell. Proof:
"protected" implies "actively needed": immediate from their existing definitions.
"actively needed" implies "protected": the key is that for an actively needed worker, "the worker's ports" is never empty, so step 3 will always return true. In particular, for dedicated workers, their implicit MessagePort can never be removed from "the worker's ports", since there is no exposed MessagePort object that could be transferred or close()ed or garbage collected. And shared workers are always protected.
Stated another way, despite the complicated definition of "protected", it is not possible to have a worker that is "actively needed" but not "protected". The extra clause about outstanding timers, database transactions, or network connections is redundant.
This is a follow-up to e9ccb97. The text prior to that revision also supports this conclusion.
It would be good to get a check on this from worker experts like @yoshisatoyanagisawa, @asutherland, or @fergald. In particular I'm curious if there was an underlying implementation distinction here, which the spec was trying to make but failed to do so.
/workers.html ( diff )