aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkThread_platform.h8
-rw-r--r--src/ports/SkThread_none.cpp22
-rw-r--r--src/ports/SkThread_pthread.cpp30
-rw-r--r--src/ports/SkThread_win.cpp18
4 files changed, 26 insertions, 52 deletions
diff --git a/include/core/SkThread_platform.h b/include/core/SkThread_platform.h
index d83f3eddb8..cbb4891c1a 100644
--- a/include/core/SkThread_platform.h
+++ b/include/core/SkThread_platform.h
@@ -59,9 +59,7 @@ SK_API int32_t sk_atomic_dec(int32_t* addr);
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(); }
@@ -82,9 +80,7 @@ SK_API int32_t sk_atomic_dec(int32_t* addr);
class SkMutex {
public:
- // if isGlobal is true, then ignore any errors in the platform-specific
- // destructor
- SkMutex(bool isGlobal = true);
+ SkMutex();
~SkMutex();
void acquire();
diff --git a/src/ports/SkThread_none.cpp b/src/ports/SkThread_none.cpp
index e70acde5c5..8361021059 100644
--- a/src/ports/SkThread_none.cpp
+++ b/src/ports/SkThread_none.cpp
@@ -9,33 +9,23 @@
#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() {}
diff --git a/src/ports/SkThread_pthread.cpp b/src/ports/SkThread_pthread.cpp
index 51c0859031..638e522e3b 100644
--- a/src/ports/SkThread_pthread.cpp
+++ b/src/ports/SkThread_pthread.cpp
@@ -67,27 +67,24 @@ int32_t sk_atomic_dec(int32_t* addr)
//////////////////////////////////////////////////////////////////////////////
-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");
}
@@ -104,27 +101,24 @@ SkMutex::SkMutex(bool isGlobal) : fIsGlobal(isGlobal)
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);
diff --git a/src/ports/SkThread_win.cpp b/src/ports/SkThread_win.cpp
index 5fa58dd803..48c1c9bc5b 100644
--- a/src/ports/SkThread_win.cpp
+++ b/src/ports/SkThread_win.cpp
@@ -10,36 +10,30 @@
#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));
}