Adam Fedor wrote:
> That being said, I could see how this type of usage could be
> beneficial. Although I do not know if the underlying thread mechanism
> supports this. I would suspect Condition Locks to be better used
> here (Unfortunately, GNUstep has the same limitation with
> NSConditonLock locks, which I am definitely more inclined to change,
> if it is possible using the underlying thread mechanism).
This isn't really a limitation when using NSConditionLock:s (and I
believe the behavior is intentional), it just makes it a bit less
obvious how to do this. What you need is something like (untested):
lock = [[NSConditionLock alloc] initWithCondition: 1];
...
numprocesses=99;
while (numprocesses >= 0)
{
[lock lockWhenCondition: 1];
[lock unlockWithCondition: 0];
[NSThread detachNewThreadSelector:@selector(doProcess:)
toTarget:anObject
withObject:anotherObject];
numprocesses --;
}
...
-(void) doProcess: ...
{
[lock lockWhenCondition: 0];
[lock unlockWithCondition: 1];
...
}
- Alexander Malmberg
_______________________________________________
Bug-gnustep mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-gnustep