[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NSSound Code Review
From: |
David Chisnall |
Subject: |
Re: NSSound Code Review |
Date: |
Wed, 29 Jul 2009 15:53:20 +0100 |
On 29 Jul 2009, at 14:25, Stef Bidi wrote:
On Wed, Jul 29, 2009 at 8:13 AM, David Chisnall <address@hidden>
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
- NSSound Code Review, Stef Bidi, 2009/07/27
- Re: NSSound Code Review, Stef Bidi, 2009/07/28
- Re: NSSound Code Review, David Ayers, 2009/07/28
- Re: NSSound Code Review, David Chisnall, 2009/07/29
- Re: NSSound Code Review, Wolfgang Lux, 2009/07/29
- Re: NSSound Code Review, David Chisnall, 2009/07/29
- Re: NSSound Code Review, David Ayers, 2009/07/29
- Re: NSSound Code Review, David Chisnall, 2009/07/29
- Re: NSSound Code Review, Stef Bidi, 2009/07/29
- Re: NSSound Code Review, David Ayers, 2009/07/30
- Re: NSSound Code Review, David Chisnall, 2009/07/30