Re: GetNumEventsInQueue() for Cocoa
Re: GetNumEventsInQueue() for Cocoa
- Subject: Re: GetNumEventsInQueue() for Cocoa
- From: Andreas Falkenhahn <email@hidden>
- Date: Sat, 20 Aug 2016 19:59:22 +0200
On 20.08.2016 at 19:48 David Duncan wrote:
>> On Aug 20, 2016, at 10:30 AM, Andreas Falkenhahn <email@hidden> wrote:
>> Is there a Cocoa equivalent for the Carbon call
>> GetNumEventsInQueue(GetMainEventQueue())?
>> I use this a lot to poll whether there are events in the queue.
> Why do you need to poll if there are events in the queue?
Because actually retrieving events is very, very expensive. I already use a timer
which limits event loop execution to about 100 times per second but I'd like to
make an exception in case there are currently events in the queue, that's why
I'm looking for a Cocoa equivalent for GetNumEventsInQueue().
Longer story:
Yes, I know, my app isn't doing things the Cocoa way but that's not possible
because it's a multi-platform app written in C and I need to make the Cocoa backend
fit into this fixed, abstracted multi-platform design. Hence, in my NSApplicationDelegate's
"didFinishLaunching" I'm immediately doing a [NSApp stop:nil] and I'm then processing
events manually using an old-school model of waitEvent() and handleEvents().
Unfortunately, the OS-independent backend calls handleEvents() really, really
often so I need a throttle to avoid killing performance of my app. The timer
throttling event loop execution to 100 times per second plus GetNumEventsInQueue()
worked like a charm on Carbon. But now I'd need a Cocoa equivalent for
GetNumEventsInQueue()...
--
Best regards,
Andreas Falkenhahn mailto:email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden