Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Unified Diff: runtime/bin/thread_linux.cc

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/thread_linux.h ('k') | runtime/bin/thread_macos.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/thread_linux.cc
diff --git a/runtime/bin/thread_linux.cc b/runtime/bin/thread_linux.cc
index ba34d5400b9dfbe8068f87be841dca5b9822fcd7..b30bbf0e994038cc8d3793bc482939f57e372c52 100644
--- a/runtime/bin/thread_linux.cc
+++ b/runtime/bin/thread_linux.cc
@@ -26,7 +26,6 @@ namespace bin {
Utils::StrError(result, error_buf, kBufferSize)); \
}
-
#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) {
int64_t secs = micros / kMicrosecondsPerSecond;
int64_t nanos =
@@ -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 pthread_self();
}
-
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 (pthread_equal(a, b) != 0);
}
-
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);
@@ -256,7 +237,6 @@ Monitor::Monitor() {
VALIDATE_PTHREAD_RESULT(result);
}
-
Monitor::~Monitor() {
int result = pthread_mutex_destroy(data_.mutex());
VALIDATE_PTHREAD_RESULT(result);
@@ -265,26 +245,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;
@@ -304,14 +280,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());
« no previous file with comments | « runtime/bin/thread_linux.h ('k') | runtime/bin/thread_macos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698