• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Delaying a method return
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Delaying a method return
      • From: Jonathon Mah <email@hidden>
    • Re: Delaying a method return
      • From: Kaelin Colclasure <email@hidden>
  • Prev by Date: Re: Classy NSSplitViews in Cocoa
  • Next by Date: Re: Dealing with non-standard character sets...
  • Previous by thread: Re: Ejecting the CD tray
  • Next by thread: Re: Delaying a method return
  • Index(es):
    • Date
    • Thread