November 1999
Intermediate to advanced
336 pages
6h 29m
English
We have already investigated two versions of reference counting and established that one (using RCPtr) was faster than the other (using RCIPtr). There's one more important twist on reference counting that we need to evaluate. The third implementation variant handles reference-counted objects in a multithreaded execution environment. In that case, multiple threads may access a reference-counted object concurrently. Therefore, the variable holding the reference count must be protected so that updates are atomic. Atomic updates require a locking mechanism. We have discussed locking classes in Chapter 7, and we reproduce the relevant code subset here:
class MutexLock { public: MutexLock() {mutex = CreateMutex(NULL, ...Read now
Unlock full access