Closed ninevra closed 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.
Since #30, the proposal spec requires that
Atomics.waitAsync()
return synchronously. This doesn't appear to be possible for polyfills that use a pool ofWorker
s andAtomics.wait()
, for a few reasons:notify()
s that happen between returning and actually waiting. The spec appears to require that the waiter be added to the waiterlist synchronously & before returning.'not-equal'
when it callsAtomics.wait()
, but has no way of synchronously communicating this to the polyfill. The spec doesn't appear to allow resolving the returned promise to'not-equal'
.polyfill.js
hasn't been updated to the post-#30 semantics; possiblyPROPOSAL.md
could be updated to clarify thatAtomics.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.)