On Apr 8, 2010, at 10:40 PM, vincent habchi wrote:
>> void CFRunLoopWakeUp(CFRunLoopRef rl) {
>>    CHECK_FOR_FORK();
>> #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED
>>    kern_return_t ret;
>>    /* We unconditionally try to send the message, since we don't want
>>     * to lose a wakeup, but the send may fail if there is already a
>>     * wakeup pending, since the queue length is 1. */
>>    ret = __CFSendTrivialMachMessage(rl->_wakeUpPort, 0, MACH_SEND_TIMEOUT, 
>> 0);
>>    if (ret != MACH_MSG_SUCCESS && ret != MACH_SEND_TIMED_OUT) {
>>      HALT;
>>    }
> 
> Okay, so that means it is impossible to ask a run loop to stop while it is 
> being messaged to wake up. Practically, this might not be a severe threat, 
> but when you begin to create/destroy threads at small intervals (say, 50 ms), 
> the collision seems to be inevitable (especially since I also use timers to 
> wake up the loops). I wonder why the queue has only a single entry.

In this circumstance, mach_msg() will block if the queue is full, and either 
succeed later or time out. Neither of those paths should end up at HALT. 
(mach_msg() may do other things in other circumstances.)

Presumably mach_msg() returned something other than MACH_MSG_SUCCESS or 
MACH_SEND_TIMED_OUT in your example. What's in register rax in your crash log?


-- 
Greg Parker     gpar...@apple.com     Runtime Wrangler


_______________________________________________

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

Reply via email to