This sounds way outside the realm of Cocoa as it doesn’t expose the means that 
you apparently are using to actually get the events, so any solution you’re 
looking for is going to be within that realm, not Cocoa.

With that being said, I’ve worked on plenty of cross-platform apps that tried 
to shoehorn one architecture into another, and if things don’t work the same 
way you’re expecting, you might find greater success by not trying.  If it is 
possible, I would suggest changing your waitEvent and handleEvents to be empty 
functions and rely upon the Cocoa event architecture.  You might try overriding 
NSApplication’s event retrieving methods to pull the results and save them off 
for your original calls.  You might try getting into the guts of runloops.  It 
all depends on what kind of things you need to do with the events before the 
real objects get them and the purpose of your cross-platform architecture.

If the architecture you’re using is something well known, you might get some 
better advice by others who have used it and how they’ve done things the Cocoa 
way.
--
Gary L. Wade
http://www.garywade.com/ <http://www.garywade.com/>
> On Aug 20, 2016, at 10:59 AM, Andreas Falkenhahn <[email protected]> 
> wrote:
> 
> On 20.08.2016 at 19:48 David Duncan wrote:
> 
> 
>>> On Aug 20, 2016, at 10:30 AM, Andreas Falkenhahn <[email protected]> 
>>> 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 protected]
> 
> _______________________________________________
> 
> Cocoa-dev mailing list ([email protected])
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/garywade%40desisoftsystems.com
> 
> This email sent to [email protected]

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to