Re: How can main thread be blocked in mach_msg_trap?
Re: How can main thread be blocked in mach_msg_trap?
- Subject: Re: How can main thread be blocked in mach_msg_trap?
- From: Eric Schlegel <email@hidden>
- Date: Sat, 21 Mar 2009 22:50:58 -0700
On Mar 21, 2009, at 8:54 PM, Jerry Krinock wrote:
NSLogs tell me that, when one of my secondary threads executes a
performSelectorOnMainThread::: at a certain point, the requested
method never begins. So I conclude that the main thread ^is^ blocked.
But if I "Pause" the debugger at this point and examine the call
stack for "Thread-1", I see:
#0 0x9540b1c6 in mach_msg_trap
#1 0x954129bc in mach_msg
#2 0x9495f0ae in CFRunLoopRunSpecific
#3 0x9495fcd8 in CFRunLoopRunInMode
#4 0x929ced75 in -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
#5 0x929dae94 in -[NSRunLoop(NSRunLoop) run]
#6 0x00002a3f in main at Worker-Main.m:112
I always thought that mach_msg_trap means that a thread is sitting
at the top of a run loop waiting for an input source, such as
performSelectorOnMainThread:::, to wake it. Therefore it is ^not^
blocked.
My understanding thus ends in a paradox. How can this be explained?
I seem to recall that performSelectorOnMainThread: might not actually
wake the main thread. You might have to wake the main thread
explicitly, for example by creating and posting a fake NSEvent. This
would accord with your description of the problem occuring in a bg-
only app that's not receiving normal user input events.
-eric
_______________________________________________
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