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

Side by Side Diff: runtime/platform/thread_android.cc

Issue 109803002: Profiler Take 2 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include "platform/thread.h" 8 #include "platform/thread.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 RETURN_ON_PTHREAD_FAILURE(result); 106 RETURN_ON_PTHREAD_FAILURE(result);
107 107
108 result = pthread_attr_destroy(&attr); 108 result = pthread_attr_destroy(&attr);
109 RETURN_ON_PTHREAD_FAILURE(result); 109 RETURN_ON_PTHREAD_FAILURE(result);
110 110
111 return 0; 111 return 0;
112 } 112 }
113 113
114 114
115 ThreadLocalKey Thread::kUnsetThreadLocalKey = static_cast<pthread_key_t>(-1); 115 ThreadLocalKey Thread::kUnsetThreadLocalKey = static_cast<pthread_key_t>(-1);
116 116 ThreadId Thread::kInvalidThreadId = static_cast<ThreadId>(0);
117 117
118 ThreadLocalKey Thread::CreateThreadLocal() { 118 ThreadLocalKey Thread::CreateThreadLocal() {
119 pthread_key_t key = kUnsetThreadLocalKey; 119 pthread_key_t key = kUnsetThreadLocalKey;
120 int result = pthread_key_create(&key, NULL); 120 int result = pthread_key_create(&key, NULL);
121 VALIDATE_PTHREAD_RESULT(result); 121 VALIDATE_PTHREAD_RESULT(result);
122 ASSERT(key != kUnsetThreadLocalKey); 122 ASSERT(key != kUnsetThreadLocalKey);
123 return key; 123 return key;
124 } 124 }
125 125
126 126
(...skipping 15 matching lines...) Expand all
142 const int kStackSize = (128 * kWordSize * KB); 142 const int kStackSize = (128 * kWordSize * KB);
143 return kStackSize; 143 return kStackSize;
144 } 144 }
145 145
146 146
147 ThreadId Thread::GetCurrentThreadId() { 147 ThreadId Thread::GetCurrentThreadId() {
148 return pthread_self(); 148 return pthread_self();
149 } 149 }
150 150
151 151
152 intptr_t Thread::ThreadIdToIntPtr(ThreadId id) {
siva 2013/12/11 02:52:21 We should probably assert that sizeof(ThreadId) is
Cutch 2013/12/11 17:44:56 Done.
153 return static_cast<intptr_t>(id);
154 }
155
156
157 bool Thread::Compare(ThreadId a, ThreadId b) {
158 return pthread_equal(a, b) != 0;
159 }
160
161
152 void Thread::GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage) { 162 void Thread::GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage) {
153 ASSERT(thread_id == GetCurrentThreadId()); 163 ASSERT(thread_id == GetCurrentThreadId());
154 ASSERT(cpu_usage != NULL); 164 ASSERT(cpu_usage != NULL);
155 struct timespec ts; 165 struct timespec ts;
156 int r = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); 166 int r = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
157 ASSERT(r == 0); 167 ASSERT(r == 0);
158 *cpu_usage = (ts.tv_sec * kNanosecondsPerSecond + ts.tv_nsec) / 168 *cpu_usage = (ts.tv_sec * kNanosecondsPerSecond + ts.tv_nsec) /
159 kNanosecondsPerMicrosecond; 169 kNanosecondsPerMicrosecond;
160 } 170 }
161 171
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 311
302 void Monitor::NotifyAll() { 312 void Monitor::NotifyAll() {
303 // TODO(iposva): Do we need to track lock owners? 313 // TODO(iposva): Do we need to track lock owners?
304 int result = pthread_cond_broadcast(data_.cond()); 314 int result = pthread_cond_broadcast(data_.cond());
305 VALIDATE_PTHREAD_RESULT(result); 315 VALIDATE_PTHREAD_RESULT(result);
306 } 316 }
307 317
308 } // namespace dart 318 } // namespace dart
309 319
310 #endif // defined(TARGET_OS_ANDROID) 320 #endif // defined(TARGET_OS_ANDROID)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698