I've recently ventured into combining AppKit with libdispatch. Previously, I've successfully used libs-base with libdispatch and [NSRunLoop run] and it all works fine and does not exhibit the symptom I am observing.
In an app that creates a window with AppKit and calls dispatch_async(dispatch_get_main_queue, ...) I am seeing the CPU spike to 100% when nothing is happening. I first noticed in a small program that had a background queue that wanted to update the display. But I have managed to illustrate the issue in a very simple program here:
I have compiled this on Ubuntu, raspberry-pi and onflapp's gs-desktop with Debian and see the same thing. If I remove calls to dispatch_async() entirely, there is no issue, but after the first call, the CPU spikes.
I've also noticed that the CPU usage drops when the widgets in the window are being manipulated. The app is performant regardless, but when nothing is happening it uses 100%.
Has anyone else seen this? Should it work? Or am I misunderstanding.
Thanks,
Tom