Re: Puzzling run loop/autorelease pool question
Re: Puzzling run loop/autorelease pool question
- Subject: Re: Puzzling run loop/autorelease pool question
- From: m <email@hidden>
- Date: Sun, 5 Apr 2009 19:31:35 -0700
Having my own autorelease pool in my call-back is an approach that I
tried, and it worked, but I was unsatisfied because from my
understanding of run loops and autorelease pools, it didn't seem like
it should be necessary.
Because my app is a Cocoa app, and everything is happening on the main
thread, there will be an autorelease pool in place. And it seems that
the run loop machinery would be designed so that the right stuff
either happens automatically, or that a way would have been be
provided to make the right stuff happen.
According to Michael's article (thanks Michael!), the former does not
appear to be the case (the right stuff doesn't happen automatically).
Something that looks like the correct solution is calling
CFRunLoopWakeUp() in the notification handler. But it doesn't fix the
problem. Bug?
So in the end, it looks like I'll have to use techniques that, as a
side effect, cause the right thing to happen.
_murat
On Apr 5, 2009, at 4:56 PM, Chris Suter wrote:
Hi Michael,
On Mon, Apr 6, 2009 at 9:50 AM, Michael Ash <email@hidden>
wrote:
On Sun, Apr 5, 2009 at 5:11 PM, m <email@hidden> wrote:
The workaround is easy. What you're doing is fine, or you can post a
fake NSEvent, or something similar. Pretty much up to you.
Whilst that approach will probably work for ever, I still think you're
better off wrapping your C callbacks with your own NSAutoreleasePool;
nothing really guarantees that an autorelease pool will exist when
you're in a C callback that you've added directly to the runloop via a
C interface.
Regards,
Chris
_______________________________________________
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