Le 18 mai 2010 à 16:34, Jonny Taylor a écrit : > Hi all, > > I have been programming on the mac for many years but have only just started > trying to get the hang of cocoa. I have a particular question about > NSNotification that I hope somebody will be able to help with. > > My code works with a firewire video camera, and receives callbacks from the > camera driver when a new video frame is received. Whenever this occurs, the > UI needs to be updated to display the latest video frame. The UI update must > run on the main thread - the callback thread is not a suitable place to do > the update. Furthermore I would like to use NSPostWhenIdle and coalescing - > if several new frames arrive between updates then we only need to draw the > most recent. > > I am not sure how I should be achieving this. > - I can call enqueueNotification on the default queue, but this will never > run since the callback thread is not running a CFRunLoop, and is not the > thread I wanted it to run on anyway. > - I could try acquiring the NSNotificationQueue for the main thread, but > there does not appear to be a standard way of doing that. I have seen this > suggested as a strategy elsewhere, but I think I have also read that one is > not meant to post to queues other than that of the current thread (not sure > why...).
Because NSNotificationQueue is explicitly documented as non thread safe: http://developer.apple.com/mac/library/documentation/cocoa/conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html -- Jean-Daniel _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com