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

Side by Side Diff: runtime/platform/thread_macos.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
« no previous file with comments | « runtime/platform/thread_linux.cc ('k') | runtime/platform/thread_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include "platform/thread.h" 8 #include "platform/thread.h"
9 9
10 #include <sys/errno.h> // NOLINT 10 #include <sys/errno.h> // NOLINT
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 RETURN_ON_PTHREAD_FAILURE(result); 99 RETURN_ON_PTHREAD_FAILURE(result);
100 100
101 result = pthread_attr_destroy(&attr); 101 result = pthread_attr_destroy(&attr);
102 RETURN_ON_PTHREAD_FAILURE(result); 102 RETURN_ON_PTHREAD_FAILURE(result);
103 103
104 return 0; 104 return 0;
105 } 105 }
106 106
107 107
108 ThreadLocalKey Thread::kUnsetThreadLocalKey = static_cast<pthread_key_t>(-1); 108 ThreadLocalKey Thread::kUnsetThreadLocalKey = static_cast<pthread_key_t>(-1);
109 109 ThreadId Thread::kInvalidThreadId = reinterpret_cast<ThreadId>(NULL);
110 110
111 ThreadLocalKey Thread::CreateThreadLocal() { 111 ThreadLocalKey Thread::CreateThreadLocal() {
112 pthread_key_t key = kUnsetThreadLocalKey; 112 pthread_key_t key = kUnsetThreadLocalKey;
113 int result = pthread_key_create(&key, NULL); 113 int result = pthread_key_create(&key, NULL);
114 VALIDATE_PTHREAD_RESULT(result); 114 VALIDATE_PTHREAD_RESULT(result);
115 ASSERT(key != kUnsetThreadLocalKey); 115 ASSERT(key != kUnsetThreadLocalKey);
116 return key; 116 return key;
117 } 117 }
118 118
119 119
(...skipping 15 matching lines...) Expand all
135 const int kStackSize = (128 * kWordSize * KB); 135 const int kStackSize = (128 * kWordSize * KB);
136 return kStackSize; 136 return kStackSize;
137 } 137 }
138 138
139 139
140 ThreadId Thread::GetCurrentThreadId() { 140 ThreadId Thread::GetCurrentThreadId() {
141 return pthread_self(); 141 return pthread_self();
142 } 142 }
143 143
144 144
145 intptr_t Thread::ThreadIdToIntPtr(ThreadId id) {
146 ASSERT(sizeof(id) == sizeof(intptr_t));
147 return reinterpret_cast<intptr_t>(id);
148 }
149
150
151 bool Thread::Compare(ThreadId a, ThreadId b) {
152 return pthread_equal(a, b) != 0;
153 }
154
155
145 void Thread::GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage) { 156 void Thread::GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage) {
146 ASSERT(thread_id == GetCurrentThreadId()); 157 ASSERT(thread_id == GetCurrentThreadId());
147 ASSERT(cpu_usage != NULL); 158 ASSERT(cpu_usage != NULL);
148 // TODO(johnmccutchan): Enable this after fixing issue with macos directory 159 // TODO(johnmccutchan): Enable this after fixing issue with macos directory
149 // watcher. 160 // watcher.
150 const bool get_cpu_usage = false; 161 const bool get_cpu_usage = false;
151 if (get_cpu_usage) { 162 if (get_cpu_usage) {
152 mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT; 163 mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
153 thread_basic_info_data_t info_data; 164 thread_basic_info_data_t info_data;
154 thread_basic_info_t info = &info_data; 165 thread_basic_info_t info = &info_data;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 317
307 void Monitor::NotifyAll() { 318 void Monitor::NotifyAll() {
308 // TODO(iposva): Do we need to track lock owners? 319 // TODO(iposva): Do we need to track lock owners?
309 int result = pthread_cond_broadcast(data_.cond()); 320 int result = pthread_cond_broadcast(data_.cond());
310 VALIDATE_PTHREAD_RESULT(result); 321 VALIDATE_PTHREAD_RESULT(result);
311 } 322 }
312 323
313 } // namespace dart 324 } // namespace dart
314 325
315 #endif // defined(TARGET_OS_MACOS) 326 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/platform/thread_linux.cc ('k') | runtime/platform/thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698