fbfcd56021
This CL is part I of IV (I broke down the 1280 files into 4 CLs). Review URL: https://codereview.appspot.com/6485054 git-svn-id: http://skia.googlecode.com/svn/trunk@5262 2bbb7eff-a529-9590-31e7-b0007b416f81
69 lines
1.3 KiB
C++
69 lines
1.3 KiB
C++
|
|
/*
|
|
* Copyright 2006 The Android Open Source Project
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
|
|
#ifndef SkThread_DEFINED
|
|
#define SkThread_DEFINED
|
|
|
|
#include "SkTypes.h"
|
|
#include "SkThread_platform.h"
|
|
|
|
/****** SkThread_platform needs to define the following...
|
|
|
|
int32_t sk_atomic_inc(int32_t*);
|
|
int32_t sk_atomic_add(int32_t*, int32_t);
|
|
int32_t sk_atomic_dec(int32_t*);
|
|
int32_t sk_atomic_conditional_inc(int32_t*);
|
|
|
|
class SkMutex {
|
|
public:
|
|
SkMutex();
|
|
~SkMutex();
|
|
|
|
void acquire();
|
|
void release();
|
|
};
|
|
|
|
****************/
|
|
|
|
class SkAutoMutexAcquire : SkNoncopyable {
|
|
public:
|
|
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) {
|
|
fMutex->release();
|
|
}
|
|
}
|
|
|
|
/** If the mutex has not been release, release it now.
|
|
*/
|
|
void release() {
|
|
if (fMutex) {
|
|
fMutex->release();
|
|
fMutex = NULL;
|
|
}
|
|
}
|
|
|
|
private:
|
|
SkBaseMutex* fMutex;
|
|
};
|
|
|
|
#endif
|