Re: Pausing and terminating a thread
Re: Pausing and terminating a thread
- Subject: Re: Pausing and terminating a thread
- From: Pandaa <email@hidden>
- Date: Wed, 31 Aug 2005 03:30:45 +0200
31 aug 2005 kl. 02.48 skrev Ben Haller:
On Aug 30, 2005, at 5:22 PM, Ryan Britton wrote:
Here's an approach I used when implementing something similar to
Finder's spotlight search window. Hopefully it should give you
some idea of how I did this.
Right; if I understand your code correctly, though, you are
polling the "stopThread" ivar every time through your loop. If
your loop took very little time to complete one iteration, that
polling would end up taking a substantial amount of the total time
taken by the thread. The only solution to that (as far as anybody
on the list so far seems to know) is unrolling the loop so that you
only have to check the flag every x iterations. That's the problem.
Nevertheless, the code is a nice illustration of what is
apparently the best way to do this sort of thing, given current
APIs. I don't mean to jump on you at all. Thanks for posting it.
Is there any reason you can't use a pthread with cancel type
PTHREAD_CANCEL_ASYNCHRONOUS and pthread_cleanup_push / pop ?
See, e.g. "Thread Cancellation And Termination" in http://
users.actcom.co.il/~choo/lupg/tutorials/multi-thread/multi-
thread.html and the man page for pthread_cleanup_push.
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. email@hidden . . www.synapticpulse.net .
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden