allow SkMutex* as an alternative arg to SkAutoMutexAcquire constructor

git-svn-id: http://skia.googlecode.com/svn/trunk@3754 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2012-04-23 16:04:22 +00:00
parent d65ad1324c
commit 064e50d495

View File

@ -31,24 +31,29 @@ public:
class SkAutoMutexAcquire : SkNoncopyable {
public:
explicit SkAutoMutexAcquire(SkBaseMutex& mutex) : fMutex(&mutex)
{
explicit SkAutoMutexAcquire(SkBaseMutex& mutex) : fMutex(&mutex) {
SkASSERT(fMutex != NULL);
mutex.acquire();
}
SkAutoMutexAcquire(SkBaseMutex* mutex) : fMutex(mutex) {
if (mutex) {
mutex->acquire();
}
}
/** If the mutex has not been release, release it now.
*/
~SkAutoMutexAcquire()
{
if (fMutex)
~SkAutoMutexAcquire() {
if (fMutex) {
fMutex->release();
}
}
/** If the mutex has not been release, release it now.
*/
void release()
{
if (fMutex)
{
void release() {
if (fMutex) {
fMutex->release();
fMutex = NULL;
}