On 2/19/20, Coda Highland <firstname.lastname@example.org> wrote:
On Wed, Feb 19, 2020 at 1:16 PM Eric Wing <email@example.com> wrote:The op's proposed code using NSApp nextEventMatchingMask is manuallypumping the event loop.
Manually pumping the event loop on macOS can work in limited cases,
but can/will break down if your application uses/interacts other
system frameworks that depend on the native event loop. Apple has
private implementation details in their event loop pump which can't be
recreated through public APIs and some of their own implementations
seem to depend on these things (or have some kind of implicit
assumptions). For example, things with modal windows, file dialogs,
and menu bar interaction may no longer work correctly. I remember a
very old bug where Game Center just wouldn't work.
I'm well aware of that fact, but... who's suggesting doing that? Queueing
up continuations on the event loop is a far better way of going about it.
Looking deeper coroutines as a possible alternative, I discovered that they are currently fundamentally broken in Hammerspoon, so working on fixing that little snafu atm... one crisis at a time, please :-)