On 29 Jul 2009, at 14:25, Stef Bidi wrote:

On Wed, Jul 29, 2009 at 8:13 AM, David Chisnall <[email protected]> wrote: That said, a number of the locks in the code under discussion are in the wrong place, and NSConditionLock appears to be consistently used incorrectly.

Can you elaborate, please? This is the first time I ever used threads and locks.

I left comments on the review board for most of them. There are a couple of things that need to be protected by locks that aren't (e.g. the sound name dictionary) and a few things that are protected by locks that are not guaranteed to be shared among the threads accessing them (e.g. the locks around the sound output object).

NSConditionLock is similar to a POSIX condition variable and should be used in the same way. You can find a good example of how it should be used on CocoaDev:

http://www.cocoadev.com/index.pl?ProducersAndConsumerModel

As I recall, you were testing the condition without locking in a few places. It seems like you are trying to use a condition variable like an integer protected by a mutex, while it is intended for letting threads sleep until a condition holds.

David


_______________________________________________
Gnustep-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to