Skip navigation.
 
mlRe: Seeking advice on NSLock usage
FROM : Nick Zitzmann
DATE : Sun Dec 12 18:48:23 2004

On Dec 12, 2004, at 8:36 AM, Jeremy Dronfield wrote:

> 1. How do locks work?


Locks work by making it so that if a -lock message is sent to a lock
that is already locked, then the thread will freeze until whatever
obtained the lock in the first place unlocks the lock. Then the other
thread will unfreeze and it will obtain the lock, and anything else
that attempts to acquire the lock will freeze until the lock is
unlocked, and so on...

> 2. It appears that NSLock can't be used with non-object variables.
> Some of my search criteria are strings, but most are BOOLs and ints.
> How can I lock those?


You can put _anything_ under the protection of an NSLock, not just
Foundation objects.

Nick Zitzmann
<http://www.chronosnet.com/>

Related mailsAuthorDate
mlSeeking advice on NSLock usage Jeremy Dronfield Dec 12, 16:36
mlRe: Seeking advice on NSLock usage Nick Zitzmann Dec 12, 18:48
mlRe: Seeking advice on NSLock usage Clark Cox Dec 13, 04:34
mlRe: Seeking advice on NSLock usage Evan Schoenberg Dec 13, 05:05
mlRe: Seeking advice on NSLock usage Andreas Mayer Dec 13, 07:38
mlRe: Seeking advice on NSLock usage Jeremy Dronfield Dec 13, 12:54
mlRe: Seeking advice on NSLock usage Guy English Dec 13, 20:48
mlRe: Seeking advice on NSLock usage Jeremy Dronfield Dec 13, 23:07