Re: Fall asleep ok, awaking ...
Re: Fall asleep ok, awaking ...
- Subject: Re: Fall asleep ok, awaking ...
- From: Brian Bergstrand <email@hidden>
- Date: Wed, 10 Nov 2004 11:32:08 -0600
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Nov 10, 2004, at 10:51 AM, ROUGE Alex wrote:
> Hi,
> Finaly I found the way to make my thread fall asleep with the
> following command...
>
> if(!runGeneration)[threadLock lockWhenCondition:HAS_DATA];
>
> where runGeneration is just a bool.
>
> So, now I must be able to awake that thread from another thread.
> I see that I must use NSConnection to do that but I do not find a easy
> to understand (for me) sample.
>
No you don't, just take the lock in your main thread (or whatever one
you want to wake the other thread from) and then unlock it with the
condition set:
(Std. "Code written in Mail" disclaimers apply)
// Main thread
[threadLock lock];
[thread unlockWithCondition:HAS_DATA];
This will wake any thread waiting on threadLock for the condition
HAS_DATA.
HTH.
Brian Bergstrand <http://www.bergstrand.org/brian/>, AIM: triryche206
PGP Key: <http://www.bergstrand.org/brian/misc/public_key.txt>
Oh, I don't blame Congress. If I had $600 billion at my disposal, I'd
be irresponsible, too. - Lichty & Wagner
As of 11:24:49 AM, iTunes is playing "Prelude No. 3" from "In the
Spanish Style" by "Christopher Parkening"
-----BEGIN PGP SIGNATURE-----
Version: PGP 8.1
iQA/AwUBQZJCjXnR2Fu2x7aiEQLudgCgiJZ7kh5Xpv13tmIpgK+TCyVAHTcAnjEK
FxkB6PW1hpxfMbVXVTLA/9Z9
=RQRS
-----END PGP SIGNATURE-----
_______________________________________________
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