w3c / web-locks

Cross-tab resource coordination API
https://w3c.github.io/web-locks/
Other
124 stars 16 forks source link

Spec behavior for terminated agents #24

Open inexorabletash opened 6 years ago

inexorabletash commented 6 years ago

Two cases need to be specified:

I don't know how to specify the "when an agent terminates" part. The association will need to be made explicit, but that part is simple.

domenic commented 6 years ago

Based on https://tc39.github.io/ecma262/#sec-agent-clusters agent termination appears to be a concept that exists, although not exactly precisely defined. Perhaps we just want to add a <dfn> around "terminate" there and reference it from the predicate.

It might also be worth thinking about agent deactivation/activation (more vague concepts mentioned in that section) and suspension/waiting via Atomics.wait. Maybe no special reactions need to happen, but I thought it'd be worth checking.

inexorabletash commented 6 years ago

Cool, thanks for the pointers @domenic !

annevk commented 6 years ago

I don't think agent termination is observable currently and we've explicitly decided against APIs exposing it for workers in the past (GC exposure concerns or some such). E.g., when you navigate a document it becomes inactive, but it might not necessarily be terminated. It's quite a bit more complex and if we actually want to expose anything there we'd need to do more digging.

inexorabletash commented 6 years ago

ISTM it's implicitly exposed in a few cases already:

But yeah, we need to be explicit about our intent and spec appropriately if if we move forward here.

asutherland commented 5 years ago

For ServiceWorker integration, I think it might make sense to invoke the agent integration logic that aborts all requests and releases all held locks if the Service Worker Has No Pending Events algorithm returns true at the same place the ServiceWorker spec invokes Try Activate we do in step 5.2 of ExtendableEvent when the last promise resolves.

Said another way, break all locks when the ServiceWorker becomes eligible for termination.

The idea here would be:

inexorabletash commented 5 years ago

Sounds reasonable to me at first glance.

Want to toss up a PR?