Re: NSCondition (unlocked when not locked)
Re: NSCondition (unlocked when not locked)
- Subject: Re: NSCondition (unlocked when not locked)
- From: Torsten Curdt <email@hidden>
- Date: Mon, 13 Jul 2009 12:33:29 +0200
Hey Greg
> You're not following the pattern laid out in the Overview setion of the
> NSCondition class reference. In particular, you don't have a boolean
> predicate, and you're not doing the task's work between the bounds of lock
> and unlock.
Hm ... but if I surround my task's work with lock/unlock wouldn't this
block the calling thread until the worker thread has done it's work?
- (void) pollNow
{
[pollingCondition lock];
[pollingCondition signal];
[pollingCondition unlock];
}
...which is absolutely not what I want.
Essentially I want something along the lines of this pseudo code:
function workNow() {
signal = YES
}
function worker() {
while(1) {
wait for 1000ms or signal == YES
signal == NO
do some work
}
}
> "A boolean predicate is an important part of the semantics of using
> conditions because of the way signaling works. Signaling a condition does
> not guarantee that the condition itself is true. There are timing issues
> involved in signaling that may cause false signals to appear.
Right. I read that. But for me false signals are not a problem. I
don't really need that guarantee. My only concern is to not have the
thread waiting without going through the loop from time to time.
cheers
--
Torsten
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden