class SkMutex : android::Mutex {
public:
- // if isGlobal is true, then ignore any errors in the platform-specific
- // destructor
- SkMutex(bool isGlobal = true) {}
+ SkMutex() {}
~SkMutex() {}
void acquire() { this->lock(); }
class SkMutex {
public:
- // if isGlobal is true, then ignore any errors in the platform-specific
- // destructor
- SkMutex(bool isGlobal = true);
+ SkMutex();
~SkMutex();
void acquire();
#include "SkThread.h"
-int32_t sk_atomic_inc(int32_t* addr)
-{
+int32_t sk_atomic_inc(int32_t* addr) {
int32_t value = *addr;
*addr = value + 1;
return value;
}
-int32_t sk_atomic_dec(int32_t* addr)
-{
+int32_t sk_atomic_dec(int32_t* addr) {
int32_t value = *addr;
*addr = value - 1;
return value;
}
-SkMutex::SkMutex(bool /* isGlobal */)
-{
-}
+SkMutex::SkMutex() {}
-SkMutex::~SkMutex()
-{
-}
+SkMutex::~SkMutex() {}
-void SkMutex::acquire()
-{
-}
+void SkMutex::acquire() {}
-void SkMutex::release()
-{
-}
+void SkMutex::release() {}
//////////////////////////////////////////////////////////////////////////////
-static void print_pthread_error(int status)
-{
+static void print_pthread_error(int status) {
switch (status) {
case 0: // success
break;
case EINVAL:
- printf("pthread error [%d] EINVAL\n", status);
+ SkDebugf("pthread error [%d] EINVAL\n", status);
break;
case EBUSY:
- printf("pthread error [%d] EBUSY\n", status);
+ SkDebugf("pthread error [%d] EBUSY\n", status);
break;
default:
- printf("pthread error [%d] unknown\n", status);
+ SkDebugf("pthread error [%d] unknown\n", status);
break;
}
}
-SkMutex::SkMutex(bool isGlobal) : fIsGlobal(isGlobal)
-{
- if (sizeof(pthread_mutex_t) > sizeof(fStorage))
- {
+SkMutex::SkMutex() {
+ if (sizeof(pthread_mutex_t) > sizeof(fStorage)) {
SkDEBUGF(("pthread mutex size = %d\n", sizeof(pthread_mutex_t)));
SkDEBUGFAIL("mutex storage is too small");
}
SkASSERT(0 == status);
}
-SkMutex::~SkMutex()
-{
+SkMutex::~SkMutex() {
int status = pthread_mutex_destroy((pthread_mutex_t*)fStorage);
-
+#if 0
// only report errors on non-global mutexes
- if (!fIsGlobal)
- {
+ if (!fIsGlobal) {
print_pthread_error(status);
SkASSERT(0 == status);
}
+#endif
}
-void SkMutex::acquire()
-{
+void SkMutex::acquire() {
int status = pthread_mutex_lock((pthread_mutex_t*)fStorage);
print_pthread_error(status);
SkASSERT(0 == status);
}
-void SkMutex::release()
-{
+void SkMutex::release() {
int status = pthread_mutex_unlock((pthread_mutex_t*)fStorage);
print_pthread_error(status);
SkASSERT(0 == status);
#include <windows.h>
#include "SkThread.h"
-int32_t sk_atomic_inc(int32_t* addr)
-{
+int32_t sk_atomic_inc(int32_t* addr) {
// InterlockedIncrement returns the new value, we want to return the old.
return InterlockedIncrement(reinterpret_cast<LONG*>(addr)) - 1;
}
-int32_t sk_atomic_dec(int32_t* addr)
-{
+int32_t sk_atomic_dec(int32_t* addr) {
return InterlockedDecrement(reinterpret_cast<LONG*>(addr)) + 1;
}
-SkMutex::SkMutex(bool /* isGlobal */)
-{
+SkMutex::SkMutex() {
SK_COMPILE_ASSERT(sizeof(fStorage) > sizeof(CRITICAL_SECTION),
NotEnoughSizeForCriticalSection);
InitializeCriticalSection(reinterpret_cast<CRITICAL_SECTION*>(&fStorage));
}
-SkMutex::~SkMutex()
-{
+SkMutex::~SkMutex() {
DeleteCriticalSection(reinterpret_cast<CRITICAL_SECTION*>(&fStorage));
}
-void SkMutex::acquire()
-{
+void SkMutex::acquire() {
EnterCriticalSection(reinterpret_cast<CRITICAL_SECTION*>(&fStorage));
}
-void SkMutex::release()
-{
+void SkMutex::release() {
LeaveCriticalSection(reinterpret_cast<CRITICAL_SECTION*>(&fStorage));
}