mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
VM: Small clean up and const-ness fix for Thread/OSThread constants.
BUG= R=srdjan@google.com Review URL: https://codereview.chromium.org/1482243006 .
This commit is contained in:
parent
5f073e7be0
commit
59fd6c8397
16 changed files with 53 additions and 35 deletions
|
@ -33,8 +33,8 @@ namespace bin {
|
|||
|
||||
class Thread {
|
||||
public:
|
||||
static ThreadLocalKey kUnsetThreadLocalKey;
|
||||
static ThreadId kInvalidThreadId;
|
||||
static const ThreadLocalKey kUnsetThreadLocalKey;
|
||||
static const ThreadId kInvalidThreadId;
|
||||
|
||||
typedef void (*ThreadStartFunction) (uword parameter);
|
||||
|
||||
|
|
|
@ -114,8 +114,9 @@ int Thread::Start(ThreadStartFunction function, uword parameter) {
|
|||
}
|
||||
|
||||
|
||||
ThreadLocalKey Thread::kUnsetThreadLocalKey = static_cast<pthread_key_t>(-1);
|
||||
ThreadId Thread::kInvalidThreadId = static_cast<ThreadId>(0);
|
||||
const ThreadLocalKey Thread::kUnsetThreadLocalKey =
|
||||
static_cast<pthread_key_t>(-1);
|
||||
const ThreadId Thread::kInvalidThreadId = static_cast<ThreadId>(0);
|
||||
|
||||
ThreadLocalKey Thread::CreateThreadLocal() {
|
||||
pthread_key_t key = kUnsetThreadLocalKey;
|
||||
|
|
|
@ -115,8 +115,9 @@ int Thread::Start(ThreadStartFunction function, uword parameter) {
|
|||
}
|
||||
|
||||
|
||||
ThreadLocalKey Thread::kUnsetThreadLocalKey = static_cast<pthread_key_t>(-1);
|
||||
ThreadId Thread::kInvalidThreadId = static_cast<ThreadId>(0);
|
||||
const ThreadLocalKey Thread::kUnsetThreadLocalKey =
|
||||
static_cast<pthread_key_t>(-1);
|
||||
const ThreadId Thread::kInvalidThreadId = static_cast<ThreadId>(0);
|
||||
|
||||
ThreadLocalKey Thread::CreateThreadLocal() {
|
||||
pthread_key_t key = kUnsetThreadLocalKey;
|
||||
|
|
|
@ -107,8 +107,9 @@ int Thread::Start(ThreadStartFunction function, uword parameter) {
|
|||
}
|
||||
|
||||
|
||||
ThreadLocalKey Thread::kUnsetThreadLocalKey = static_cast<pthread_key_t>(-1);
|
||||
ThreadId Thread::kInvalidThreadId = reinterpret_cast<ThreadId>(NULL);
|
||||
const ThreadLocalKey Thread::kUnsetThreadLocalKey =
|
||||
static_cast<pthread_key_t>(-1);
|
||||
const ThreadId Thread::kInvalidThreadId = reinterpret_cast<ThreadId>(NULL);
|
||||
|
||||
ThreadLocalKey Thread::CreateThreadLocal() {
|
||||
pthread_key_t key = kUnsetThreadLocalKey;
|
||||
|
|
|
@ -70,8 +70,8 @@ int Thread::Start(ThreadStartFunction function, uword parameter) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
ThreadLocalKey Thread::kUnsetThreadLocalKey = TLS_OUT_OF_INDEXES;
|
||||
ThreadId Thread::kInvalidThreadId = 0;
|
||||
const ThreadLocalKey Thread::kUnsetThreadLocalKey = TLS_OUT_OF_INDEXES;
|
||||
const ThreadId Thread::kInvalidThreadId = 0;
|
||||
|
||||
ThreadLocalKey Thread::CreateThreadLocal() {
|
||||
ThreadLocalKey key = TlsAlloc();
|
||||
|
|
|
@ -64,7 +64,7 @@ DEFINE_FLAG(bool, trace_api, false,
|
|||
DEFINE_FLAG(bool, verify_acquired_data, false,
|
||||
"Verify correct API acquire/release of typed data.");
|
||||
|
||||
ThreadLocalKey Api::api_native_key_ = OSThread::kUnsetThreadLocalKey;
|
||||
ThreadLocalKey Api::api_native_key_ = kUnsetThreadLocalKey;
|
||||
Dart_Handle Api::true_handle_ = NULL;
|
||||
Dart_Handle Api::false_handle_ = NULL;
|
||||
Dart_Handle Api::null_handle_ = NULL;
|
||||
|
@ -484,9 +484,9 @@ ApiLocalScope* Api::TopScope(Thread* thread) {
|
|||
|
||||
|
||||
void Api::InitOnce() {
|
||||
ASSERT(api_native_key_ == OSThread::kUnsetThreadLocalKey);
|
||||
ASSERT(api_native_key_ == kUnsetThreadLocalKey);
|
||||
api_native_key_ = OSThread::CreateThreadLocal();
|
||||
ASSERT(api_native_key_ != OSThread::kUnsetThreadLocalKey);
|
||||
ASSERT(api_native_key_ != kUnsetThreadLocalKey);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace dart {
|
|||
|
||||
// The single thread local key which stores all the thread local data
|
||||
// for a thread.
|
||||
ThreadLocalKey OSThread::thread_key_ = OSThread::kUnsetThreadLocalKey;
|
||||
ThreadLocalKey OSThread::thread_key_ = kUnsetThreadLocalKey;
|
||||
OSThread* OSThread::thread_list_head_ = NULL;
|
||||
Mutex* OSThread::thread_list_lock_ = NULL;
|
||||
|
||||
|
|
|
@ -177,9 +177,8 @@ class OSThread : public BaseThread {
|
|||
|
||||
static const intptr_t kStackSizeBuffer = (4 * KB * kWordSize);
|
||||
|
||||
static ThreadLocalKey kUnsetThreadLocalKey;
|
||||
static ThreadId kInvalidThreadId;
|
||||
static ThreadJoinId kInvalidThreadJoinId;
|
||||
static const ThreadId kInvalidThreadId;
|
||||
static const ThreadJoinId kInvalidThreadJoinId;
|
||||
|
||||
private:
|
||||
// These methods should not be used in a generic way and hence
|
||||
|
|
|
@ -129,10 +129,10 @@ int OSThread::Start(const char* name,
|
|||
}
|
||||
|
||||
|
||||
ThreadLocalKey OSThread::kUnsetThreadLocalKey =
|
||||
static_cast<pthread_key_t>(-1);
|
||||
ThreadId OSThread::kInvalidThreadId = static_cast<ThreadId>(0);
|
||||
ThreadJoinId OSThread::kInvalidThreadJoinId = static_cast<ThreadJoinId>(0);
|
||||
const ThreadId OSThread::kInvalidThreadId = static_cast<ThreadId>(0);
|
||||
const ThreadJoinId OSThread::kInvalidThreadJoinId =
|
||||
static_cast<ThreadJoinId>(0);
|
||||
|
||||
|
||||
ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) {
|
||||
pthread_key_t key = kUnsetThreadLocalKey;
|
||||
|
|
|
@ -20,13 +20,17 @@ typedef pthread_key_t ThreadLocalKey;
|
|||
typedef pid_t ThreadId;
|
||||
typedef pthread_t ThreadJoinId;
|
||||
|
||||
|
||||
static const ThreadLocalKey kUnsetThreadLocalKey =
|
||||
static_cast<pthread_key_t>(-1);
|
||||
|
||||
|
||||
class ThreadInlineImpl {
|
||||
private:
|
||||
ThreadInlineImpl() {}
|
||||
~ThreadInlineImpl() {}
|
||||
|
||||
static uword GetThreadLocal(ThreadLocalKey key) {
|
||||
static ThreadLocalKey kUnsetThreadLocalKey = static_cast<pthread_key_t>(-1);
|
||||
ASSERT(key != kUnsetThreadLocalKey);
|
||||
return reinterpret_cast<uword>(pthread_getspecific(key));
|
||||
}
|
||||
|
|
|
@ -131,10 +131,10 @@ int OSThread::Start(const char* name,
|
|||
}
|
||||
|
||||
|
||||
ThreadLocalKey OSThread::kUnsetThreadLocalKey =
|
||||
static_cast<pthread_key_t>(-1);
|
||||
ThreadId OSThread::kInvalidThreadId = static_cast<ThreadId>(0);
|
||||
ThreadJoinId OSThread::kInvalidThreadJoinId = static_cast<ThreadJoinId>(0);
|
||||
const ThreadId OSThread::kInvalidThreadId = static_cast<ThreadId>(0);
|
||||
const ThreadJoinId OSThread::kInvalidThreadJoinId =
|
||||
static_cast<ThreadJoinId>(0);
|
||||
|
||||
|
||||
ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) {
|
||||
pthread_key_t key = kUnsetThreadLocalKey;
|
||||
|
|
|
@ -20,13 +20,17 @@ typedef pthread_key_t ThreadLocalKey;
|
|||
typedef pthread_t ThreadId;
|
||||
typedef pthread_t ThreadJoinId;
|
||||
|
||||
|
||||
static const ThreadLocalKey kUnsetThreadLocalKey =
|
||||
static_cast<pthread_key_t>(-1);
|
||||
|
||||
|
||||
class ThreadInlineImpl {
|
||||
private:
|
||||
ThreadInlineImpl() {}
|
||||
~ThreadInlineImpl() {}
|
||||
|
||||
static uword GetThreadLocal(ThreadLocalKey key) {
|
||||
static ThreadLocalKey kUnsetThreadLocalKey = static_cast<pthread_key_t>(-1);
|
||||
ASSERT(key != kUnsetThreadLocalKey);
|
||||
return reinterpret_cast<uword>(pthread_getspecific(key));
|
||||
}
|
||||
|
|
|
@ -122,12 +122,11 @@ int OSThread::Start(const char* name,
|
|||
}
|
||||
|
||||
|
||||
ThreadLocalKey OSThread::kUnsetThreadLocalKey =
|
||||
static_cast<pthread_key_t>(-1);
|
||||
ThreadId OSThread::kInvalidThreadId = reinterpret_cast<ThreadId>(NULL);
|
||||
ThreadJoinId OSThread::kInvalidThreadJoinId =
|
||||
const ThreadId OSThread::kInvalidThreadId = reinterpret_cast<ThreadId>(NULL);
|
||||
const ThreadJoinId OSThread::kInvalidThreadJoinId =
|
||||
reinterpret_cast<ThreadJoinId>(NULL);
|
||||
|
||||
|
||||
ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) {
|
||||
pthread_key_t key = kUnsetThreadLocalKey;
|
||||
int result = pthread_key_create(&key, destructor);
|
||||
|
|
|
@ -20,6 +20,11 @@ typedef pthread_key_t ThreadLocalKey;
|
|||
typedef pthread_t ThreadId;
|
||||
typedef pthread_t ThreadJoinId;
|
||||
|
||||
|
||||
static const ThreadLocalKey kUnsetThreadLocalKey =
|
||||
static_cast<pthread_key_t>(-1);
|
||||
|
||||
|
||||
class ThreadInlineImpl {
|
||||
private:
|
||||
ThreadInlineImpl() {}
|
||||
|
|
|
@ -86,9 +86,10 @@ int OSThread::Start(const char* name,
|
|||
return 0;
|
||||
}
|
||||
|
||||
ThreadLocalKey OSThread::kUnsetThreadLocalKey = TLS_OUT_OF_INDEXES;
|
||||
ThreadId OSThread::kInvalidThreadId = 0;
|
||||
ThreadJoinId OSThread::kInvalidThreadJoinId = 0;
|
||||
|
||||
const ThreadId OSThread::kInvalidThreadId = 0;
|
||||
const ThreadJoinId OSThread::kInvalidThreadJoinId = 0;
|
||||
|
||||
|
||||
ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) {
|
||||
ThreadLocalKey key = TlsAlloc();
|
||||
|
|
|
@ -20,13 +20,16 @@ typedef DWORD ThreadLocalKey;
|
|||
typedef DWORD ThreadId;
|
||||
typedef DWORD ThreadJoinId;
|
||||
|
||||
|
||||
static const ThreadLocalKey kUnsetThreadLocalKey = TLS_OUT_OF_INDEXES;
|
||||
|
||||
|
||||
class ThreadInlineImpl {
|
||||
private:
|
||||
ThreadInlineImpl() {}
|
||||
~ThreadInlineImpl() {}
|
||||
|
||||
static uword GetThreadLocal(ThreadLocalKey key) {
|
||||
static ThreadLocalKey kUnsetThreadLocalKey = TLS_OUT_OF_INDEXES;
|
||||
ASSERT(key != kUnsetThreadLocalKey);
|
||||
return reinterpret_cast<uword>(TlsGetValue(key));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue