Index: runtime/bin/thread_android.cc |
diff --git a/runtime/bin/thread_android.cc b/runtime/bin/thread_android.cc |
index d6035ad4301366bcc1d2fde1dd74b223a28fc101..ab0d7a27b1e0406a42801661327685c421e7c010 100644 |
--- a/runtime/bin/thread_android.cc |
+++ b/runtime/bin/thread_android.cc |
@@ -25,7 +25,6 @@ namespace bin { |
FATAL2("pthread error: %d (%s)", result, error_message); \ |
} |
- |
#ifdef DEBUG |
#define RETURN_ON_PTHREAD_FAILURE(result) \ |
if (result != 0) { \ |
@@ -43,7 +42,6 @@ namespace bin { |
} |
#endif |
- |
static void ComputeTimeSpecMicros(struct timespec* ts, int64_t micros) { |
struct timeval tv; |
int64_t secs = micros / kMicrosecondsPerSecond; |
@@ -58,7 +56,6 @@ static void ComputeTimeSpecMicros(struct timespec* ts, int64_t micros) { |
} |
} |
- |
class ThreadStartData { |
public: |
ThreadStartData(Thread::ThreadStartFunction function, uword parameter) |
@@ -74,7 +71,6 @@ class ThreadStartData { |
DISALLOW_COPY_AND_ASSIGN(ThreadStartData); |
}; |
- |
// Dispatch to the thread start function provided by the caller. This trampoline |
// is used to ensure that the thread is properly destroyed if the thread just |
// exits. |
@@ -91,7 +87,6 @@ static void* ThreadStart(void* data_ptr) { |
return NULL; |
} |
- |
int Thread::Start(ThreadStartFunction function, uword parameter) { |
pthread_attr_t attr; |
int result = pthread_attr_init(&attr); |
@@ -115,7 +110,6 @@ int Thread::Start(ThreadStartFunction function, uword parameter) { |
return 0; |
} |
- |
const ThreadLocalKey Thread::kUnsetThreadLocalKey = |
static_cast<pthread_key_t>(-1); |
const ThreadId Thread::kInvalidThreadId = static_cast<ThreadId>(0); |
@@ -128,48 +122,40 @@ ThreadLocalKey Thread::CreateThreadLocal() { |
return key; |
} |
- |
void Thread::DeleteThreadLocal(ThreadLocalKey key) { |
ASSERT(key != kUnsetThreadLocalKey); |
int result = pthread_key_delete(key); |
VALIDATE_PTHREAD_RESULT(result); |
} |
- |
void Thread::SetThreadLocal(ThreadLocalKey key, uword value) { |
ASSERT(key != kUnsetThreadLocalKey); |
int result = pthread_setspecific(key, reinterpret_cast<void*>(value)); |
VALIDATE_PTHREAD_RESULT(result); |
} |
- |
intptr_t Thread::GetMaxStackSize() { |
const int kStackSize = (128 * kWordSize * KB); |
return kStackSize; |
} |
- |
ThreadId Thread::GetCurrentThreadId() { |
return gettid(); |
} |
- |
intptr_t Thread::ThreadIdToIntPtr(ThreadId id) { |
ASSERT(sizeof(id) == sizeof(intptr_t)); |
return static_cast<intptr_t>(id); |
} |
- |
bool Thread::Compare(ThreadId a, ThreadId b) { |
return (a == b); |
} |
- |
void Thread::InitOnce() { |
// Nothing to be done. |
} |
- |
Mutex::Mutex() { |
pthread_mutexattr_t attr; |
int result = pthread_mutexattr_init(&attr); |
@@ -188,14 +174,12 @@ Mutex::Mutex() { |
VALIDATE_PTHREAD_RESULT(result); |
} |
- |
Mutex::~Mutex() { |
int result = pthread_mutex_destroy(data_.mutex()); |
// Verify that the pthread_mutex was destroyed. |
VALIDATE_PTHREAD_RESULT(result); |
} |
- |
void Mutex::Lock() { |
int result = pthread_mutex_lock(data_.mutex()); |
// Specifically check for dead lock to help debugging. |
@@ -204,7 +188,6 @@ void Mutex::Lock() { |
// TODO(iposva): Do we need to track lock owners? |
} |
- |
bool Mutex::TryLock() { |
int result = pthread_mutex_trylock(data_.mutex()); |
// Return false if the lock is busy and locking failed. |
@@ -216,7 +199,6 @@ bool Mutex::TryLock() { |
return true; |
} |
- |
void Mutex::Unlock() { |
// TODO(iposva): Do we need to track lock owners? |
int result = pthread_mutex_unlock(data_.mutex()); |
@@ -225,7 +207,6 @@ void Mutex::Unlock() { |
ASSERT(result == 0); // Verify no other errors. |
} |
- |
Monitor::Monitor() { |
pthread_mutexattr_t mutex_attr; |
int result = pthread_mutexattr_init(&mutex_attr); |
@@ -253,7 +234,6 @@ Monitor::Monitor() { |
VALIDATE_PTHREAD_RESULT(result); |
} |
- |
Monitor::~Monitor() { |
int result = pthread_mutex_destroy(data_.mutex()); |
VALIDATE_PTHREAD_RESULT(result); |
@@ -262,26 +242,22 @@ Monitor::~Monitor() { |
VALIDATE_PTHREAD_RESULT(result); |
} |
- |
void Monitor::Enter() { |
int result = pthread_mutex_lock(data_.mutex()); |
VALIDATE_PTHREAD_RESULT(result); |
// TODO(iposva): Do we need to track lock owners? |
} |
- |
void Monitor::Exit() { |
// TODO(iposva): Do we need to track lock owners? |
int result = pthread_mutex_unlock(data_.mutex()); |
VALIDATE_PTHREAD_RESULT(result); |
} |
- |
Monitor::WaitResult Monitor::Wait(int64_t millis) { |
return WaitMicros(millis * kMicrosecondsPerMillisecond); |
} |
- |
Monitor::WaitResult Monitor::WaitMicros(int64_t micros) { |
// TODO(iposva): Do we need to track lock owners? |
Monitor::WaitResult retval = kNotified; |
@@ -301,14 +277,12 @@ Monitor::WaitResult Monitor::WaitMicros(int64_t micros) { |
return retval; |
} |
- |
void Monitor::Notify() { |
// TODO(iposva): Do we need to track lock owners? |
int result = pthread_cond_signal(data_.cond()); |
VALIDATE_PTHREAD_RESULT(result); |
} |
- |
void Monitor::NotifyAll() { |
// TODO(iposva): Do we need to track lock owners? |
int result = pthread_cond_broadcast(data_.cond()); |