RE: question for CFRunLoopStop()
RE: question for CFRunLoopStop()
- Subject: RE: question for CFRunLoopStop()
- From: "Philip Lukidis" <email@hidden>
- Date: Fri, 5 May 2006 16:59:45 -0400
- Thread-topic: question for CFRunLoopStop()
Thanks for your help in this matter. Using this approach seems to work
fine.
Philip Lukidis
-----Original Message-----
From: Kevin Van Vechten [mailto:email@hidden]
Sent: Friday, May 05, 2006 3:55 PM
To: Philip Lukidis
Cc: Darwin development list
Subject: Re: question for CFRunLoopStop()
The parent thread needs to retain the child's runloop to ensure it
has a valid reference when the call to CFRunLoopStop is made. You'll
need to do some synchronization around the hand-off of the runloop
reference from child to parent to ensure correctness.
If properly retained, the run loop reference should remain valid
after the child thread exits.
- Kevin
On May 5, 2006, at 11:36 AM, Philip Lukidis wrote:
> I forgot to mention the symptoms to my problem. The problem
> followed the scenario laid out in the case of the parent thread
> running down the child thread, which had a timer on its runloop.
> Sometimes the child "timer thread" had exited by the time the
> parent called CFRunLoopStop() was (so the parent was scribbling in
> random memory, as the runloop was deallocated). But I figured out
> the parent was provoking the child to exit by removing the timer
> from the runloop, so there was an actual race condition here.
>
> Would it be better for the parent to remove the timer from the
> loop, or call CFRunLoopStop()?
>
> thanks,
>
> Philip Lukidis
>
> -----Original Message-----
> From: darwin-dev-bounces+plukidis=email@hidden
> [mailto:darwin-dev-bounces+plukidis=email@hidden]On
> Behalf Of Philip Lukidis
> Sent: Friday, May 05, 2006 11:47 AM
> To: email@hidden
> Subject: question for CFRunLoopStop()
>
>
> Hello. I hope that I'm posting this to the correct list.
>
> Concerning CF, I was wondering if the following scenario is correct:
> A "parent" thread creates a child thread via the pthread library.
> The child thread has only 1 runloop source on it (a timer in fact),
> and once the timer is applied onto the child runloop by the child
> itself, the child proceeds to call CFRunLoopRun() on itself. Now
> the parent is responsible for running down this child on demand.
> Can the parent rundown the child by:
> -invalidating the timer (via CFRunLoopTimerInvalidate())
> -removing the timer (via CFRunLoopRemoveTimer())
> -calling CFRunLoopIsWaiting() in a while loop until it returns
> true (which indicates that all callbacks have drained and that it
> is waiting again, but of course since the timer was invalidated it
> can never be called again). Of course I should NOT holding a
> resource which the callback might need in order to execute and exit.
> -calling CFRunLoopStop()
> -calling pthread_join() on the pthread
>
> Can this also be extended to other runloop sources, by using
> CFRunLoopSourceInvalidate() instead of CFRunLoopTimerInvalidate(),
> and CFRunLoopRemoveSource() instead of CFRunLoopRemoveTimer()?
>
> If these procedures are incorrect, why so, and what are the
> alternatives?
>
> thanks,
>
> Philip Lukidis
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Darwin-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> 40guillemot.com
>
> This email sent to email@hidden
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Darwin-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> 40opendarwin.org
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden