GPBase& GPBase::assign (const GPBase &sptr) { gcsCounter.lock(); if (sptr.ptr) { sptr.ptr->count++; } if (ptr) { GPEnabled *old = ptr; ptr = sptr.ptr; if (! --old->count) old->count = -1; gcsCounter.unlock(); if (old->count < 0) old->destroy(); } else { ptr = sptr.ptr; gcsCounter.unlock(); } return *this; }
GPBase& GPBase::assign (GPEnabled *nptr) { gcsCounter.lock(); if (nptr) { if (nptr->count >= 0) nptr->count++; else nptr = 0; } if (ptr) { GPEnabled *old = ptr; ptr = nptr; if (! --old->count) old->count = -1; gcsCounter.unlock(); if (old->count < 0) old->destroy(); } else { ptr = nptr; gcsCounter.unlock(); } return *this; }
void GPEnabled::ref() { gcsCounter.lock(); count++; gcsCounter.unlock(); }
void GPEnabled::unref() { gcsCounter.lock(); if (! --count) count = -1; gcsCounter.unlock(); if (count < 0) destroy(); }
void DjVuDebug::unlock() { debug_lock.unlock(); }