/* * Copyright 2014 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file.
*/ #include"src/core/SkCachedData.h"
void SkCachedData::internalUnref(bool fromCache) const { if (AutoMutexWritable(this)->inMutexUnref(fromCache)) { // can't delete inside doInternalUnref, since it is locking a mutex (which we own) deletethis;
}
}
bool SkCachedData::inMutexUnref(bool fromCache) { switch (--fRefCnt) { case 0: // we're going to be deleted, so we need to be unlocked (for DiscardableMemory) if (fIsLocked) {
this->inMutexUnlock();
} break; case 1: if (fInCache && !fromCache) { // If we're down to 1 owner, and that owner is the cache, this it is safe // to unlock (and mutate fData) even if the cache is in a different thread, // as the cache is NOT allowed to inspect or use fData.
this->inMutexUnlock();
} break; default: break;
}
if (fromCache) {
SkASSERT(fInCache);
fInCache = false;
}
// return true when we need to be deleted return 0 == fRefCnt;
}
switch (fStorageType) { case kMalloc_StorageType: // nothing to do/check break; case kDiscardableMemory_StorageType: if (fData) { // did the previous lock succeed?
fStorage.fDM->unlock();
} break;
}
this->setData(nullptr); // signal that we're in an unlocked state
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.