|
From: | Richard Frith-Macdonald |
Subject: | Possible code simplification and optimisation |
Date: | Wed, 22 Oct 2003 12:53:59 +0100 |
The idea of these is to be used to simplify stuff a bit with respect to threading - If we have a single threaded application, we don't want to waste time locking/unlocking mutexes pointlessly, but if we become multithreaded, we want any classes that need locks to have those locks in the correct state.
So, a GSLazyLock keeps track of its own state in a BOOL, and metamorphoses into an NSLock when the program becomes multithreaded, while a GSRecursiveLock keeps track of the number of times it has been locked in a counter. Classes using these locks can therefore be coded with no need to be aware of whether the program is running in single or multi-threaded mode.
Now -I could add these as private classes and use them internally in the base library or I could add them as public classes in the Additions part of the base library or I could change the existing NSLock/NSRecursiveLock classes so that they do the same sort of thing.
Thoughts/comments?
[Prev in Thread] | Current Thread | [Next in Thread] |