Delaying a method return
Delaying a method return
- Subject: Delaying a method return
- From: Steve Weller <email@hidden>
- Date: Fri, 7 Oct 2005 22:36:51 -0700
I have a method that returns some data. There is a worker thread that
could be modifying that data, so I call a stopCalculation method that
tells the other thread to stop and exit. However the worker thread
could take a little while to stop since it polls the variable set by
stopCalculation every so often. I know when it has actually stopped
because it calls a didStop delegate method. This works and is
protected against race conditions by a lock.
My question is, after telling the worker thread to stop, how do I
wait for didStop?
I can think of two ways:
1) wait on a semaphore and have the didStop method access the semaphore
2) implement a -stopCalculation:andWait method that does the waiting
for me (probably by means of a semaphore)
Is there an advantage to doing it via 1) or 2)?
Is there another way that I should be considering?
--
Watch me learn Cocoa http://homepage.mac.com/bagelturf/
_______________________________________________
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