On 1 August 2012 11:05, David Symonds <
dsym...@golang.org> wrote:
> On Wed, Aug 1, 2012 at 11:01 AM, Andrew Gerrand <
a...@golang.org> wrote:
>
>> On 1 August 2012 10:58, Luke Scott <
lu...@visionlaunchers.com> wrote:
>>> if(barcode != nil && [mutex tryLock] == YES)
>>> {
>>> [delegate performSelectorOnMainThread:@selector(barcodeScanned:)
>>> withObject:barcode waitUntilDone:YES];
>>> [self stopCamera];
>>> [mutex unlock];
>>> }
>>
>> This is inherently racy. What if tryLock returns true, and then the
>> holder of the lock releases it immediately afterward?
>
> Actually Luke's code is fine (Objective C's [mutex tryLock] will grab
> the lock; think of it as a non-blocking Lock), but it's easy to get it
> wrong.