FROM : Jeremy Dronfield
DATE : Sun Dec 12 16:36:17 2004
I have an application which carries out file system searches according
to criteria set by the user. Searching is done in a separate thread, so
as not to lock up the program. Whilst a search is going on, the user is
thus able to tinker with the controls which set search criteria.
Disabling the interface seems a clumsy solution, so this seems like a
case for using locks. I've read what I can find about them, but I have
two outstanding questions.
1. How do locks work? When a lock is activated inside a setter method,
does it, in effect, disable the setter method by blocking changes to
the variable? - or does it create a locked copy of the variable at the
time when the program goes multithreaded, leaving the rest of the
program free to alter it?
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? Will I have to change them to NSNumbers, or is there some
other approach?
All advice appreciated. Regards,
Jeremy
DATE : Sun Dec 12 16:36:17 2004
I have an application which carries out file system searches according
to criteria set by the user. Searching is done in a separate thread, so
as not to lock up the program. Whilst a search is going on, the user is
thus able to tinker with the controls which set search criteria.
Disabling the interface seems a clumsy solution, so this seems like a
case for using locks. I've read what I can find about them, but I have
two outstanding questions.
1. How do locks work? When a lock is activated inside a setter method,
does it, in effect, disable the setter method by blocking changes to
the variable? - or does it create a locked copy of the variable at the
time when the program goes multithreaded, leaving the rest of the
program free to alter it?
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? Will I have to change them to NSNumbers, or is there some
other approach?
All advice appreciated. Regards,
Jeremy
| Related mails | Author | Date |
|---|---|---|
| Jeremy Dronfield | Dec 12, 16:36 | |
| Nick Zitzmann | Dec 12, 18:48 | |
| Clark Cox | Dec 13, 04:34 | |
| Evan Schoenberg | Dec 13, 05:05 | |
| Andreas Mayer | Dec 13, 07:38 | |
| Jeremy Dronfield | Dec 13, 12:54 | |
| Guy English | Dec 13, 20:48 | |
| Jeremy Dronfield | Dec 13, 23:07 |






Cocoa mail archive

