Re: Techniques for thread communication
Re: Techniques for thread communication
- Subject: Re: Techniques for thread communication
- From: Cameron Hayne <email@hidden>
- Date: Tue, 09 Sep 2003 00:51:50 -0400
On 8/9/03 1:56 PM, "Eric Scharff" <email@hidden> wrote:
>
Set up an NSTimer on the main thread, that every N seconds
>
queries the worker thread for the best result so far, and
>
displays it. Since there is always a "best so far", this method
>
is always meaningful.
I have a sample project "ImageCalc" that does something analogous to what
you are doing. I use a timer to regulate the view updates in the manner you
suggested above. I use two NSLock's to control access to the shared
(calculated) data. (I need two locks since each of the two threads both
reads and writes the data and I don't want any reading while the writing is
in-progress or writing while the reading is in-progress.)
You can download my sample code at:
http://hayne.net/MacDev/ImageCalc/
--
Cameron Hayne (email@hidden)
Hayne of Tintagel
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.