tc39 / proposal-atomics-wait-async

"asynchronous atomic wait" for ECMAScript
https://tc39.github.io/proposal-atomics-wait-async/
Other
90 stars 18 forks source link

Synchronous return can't be accurately polyfilled #32

Closed ninevra closed 3 years ago

ninevra commented 3 years ago

Since #30, the proposal spec requires that Atomics.waitAsync() return synchronously. This doesn't appear to be possible for polyfills that use a pool of Workers and Atomics.wait(), for a few reasons:

polyfill.js hasn't been updated to the post-#30 semantics; possibly PROPOSAL.md could be updated to clarify that Atomics.waitAsync() can't be accurately polyfilled?

(Forgive me if this is incorrect / already known / not of concern. I couldn't find any prior discussion of the impact on polyfills.)

syg commented 3 years ago

Thanks for reporting this issue. I agree with your analysis and think you're right that the "fail fast synchronously" semantics cannot be accurately polyfilled using Atomics.wait given the inability to atomically know if a wait was successfully started.

The polyfill is not maintained at all, I'll update the readme to reflect that it is of historical interest only, and that an accurate polyfill is not possible on the web without sync communication to the main thread.