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

Side by Side Diff: runtime/bin/thread_macos.cc

Issue 2613283002: Fuchsia: Use new call to get thread CPU time (Closed)
Patch Set: Delete dead code Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « runtime/bin/thread_linux.cc ('k') | runtime/bin/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 "bin/thread.h" 8 #include "bin/thread.h"
9 #include "bin/thread_macos.h" 9 #include "bin/thread_macos.h"
10 10
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 ASSERT(sizeof(id) == sizeof(intptr_t)); 151 ASSERT(sizeof(id) == sizeof(intptr_t));
152 return reinterpret_cast<intptr_t>(id); 152 return reinterpret_cast<intptr_t>(id);
153 } 153 }
154 154
155 155
156 bool Thread::Compare(ThreadId a, ThreadId b) { 156 bool Thread::Compare(ThreadId a, ThreadId b) {
157 return (pthread_equal(a, b) != 0); 157 return (pthread_equal(a, b) != 0);
158 } 158 }
159 159
160 160
161 void Thread::GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage) {
162 ASSERT(thread_id == GetCurrentThreadId());
163 ASSERT(cpu_usage != NULL);
164 // TODO(johnmccutchan): Enable this after fixing issue with macos directory
165 // watcher.
166 const bool get_cpu_usage = false;
167 if (get_cpu_usage) {
168 mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
169 thread_basic_info_data_t info_data;
170 thread_basic_info_t info = &info_data;
171 mach_port_t thread_port = mach_thread_self();
172 kern_return_t r = thread_info(thread_port, THREAD_BASIC_INFO,
173 (thread_info_t)info, &count);
174 mach_port_deallocate(mach_task_self(), thread_port);
175 if (r == KERN_SUCCESS) {
176 *cpu_usage = (info->user_time.seconds * kMicrosecondsPerSecond) +
177 info->user_time.microseconds;
178 return;
179 }
180 }
181 *cpu_usage = 0;
182 }
183
184
185 void Thread::InitOnce() { 161 void Thread::InitOnce() {
186 // Nothing to be done. 162 // Nothing to be done.
187 } 163 }
188 164
189 165
190 Mutex::Mutex() { 166 Mutex::Mutex() {
191 pthread_mutexattr_t attr; 167 pthread_mutexattr_t attr;
192 int result = pthread_mutexattr_init(&attr); 168 int result = pthread_mutexattr_init(&attr);
193 VALIDATE_PTHREAD_RESULT(result); 169 VALIDATE_PTHREAD_RESULT(result);
194 170
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 void Monitor::NotifyAll() { 307 void Monitor::NotifyAll() {
332 // TODO(iposva): Do we need to track lock owners? 308 // TODO(iposva): Do we need to track lock owners?
333 int result = pthread_cond_broadcast(data_.cond()); 309 int result = pthread_cond_broadcast(data_.cond());
334 VALIDATE_PTHREAD_RESULT(result); 310 VALIDATE_PTHREAD_RESULT(result);
335 } 311 }
336 312
337 } // namespace bin 313 } // namespace bin
338 } // namespace dart 314 } // namespace dart
339 315
340 #endif // defined(TARGET_OS_MACOS) 316 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/thread_linux.cc ('k') | runtime/bin/thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698