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

Side by Side Diff: src/platform-openbsd.cc

Issue 6070009: Added labelled thread names to help with some debugging activity. Right now,... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « src/platform-nullos.cc ('k') | src/platform-solaris.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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 return pthread_equal(data_->thread_, pthread_self()); 380 return pthread_equal(data_->thread_, pthread_self());
381 } 381 }
382 382
383 383
384 bool ThreadHandle::IsValid() const { 384 bool ThreadHandle::IsValid() const {
385 return data_->thread_ != kNoThread; 385 return data_->thread_ != kNoThread;
386 } 386 }
387 387
388 388
389 Thread::Thread() : ThreadHandle(ThreadHandle::INVALID) { 389 Thread::Thread() : ThreadHandle(ThreadHandle::INVALID) {
390 set_name("v8:<unknown>");
391 }
392
393
394 Thread::Thread(const char* name) : ThreadHandle(ThreadHandle::INVALID) {
395 set_name(name);
390 } 396 }
391 397
392 398
393 Thread::~Thread() { 399 Thread::~Thread() {
394 } 400 }
395 401
396 402
397 static void* ThreadEntry(void* arg) { 403 static void* ThreadEntry(void* arg) {
398 Thread* thread = reinterpret_cast<Thread*>(arg); 404 Thread* thread = reinterpret_cast<Thread*>(arg);
399 // This is also initialized by the first argument to pthread_create() but we 405 // This is also initialized by the first argument to pthread_create() but we
400 // don't know which thread will run first (the original thread or the new 406 // don't know which thread will run first (the original thread or the new
401 // one) so we initialize it here too. 407 // one) so we initialize it here too.
402 thread->thread_handle_data()->thread_ = pthread_self(); 408 thread->thread_handle_data()->thread_ = pthread_self();
403 ASSERT(thread->IsValid()); 409 ASSERT(thread->IsValid());
404 thread->Run(); 410 thread->Run();
405 return NULL; 411 return NULL;
406 } 412 }
407 413
408 414
415 void Thread::set_name(const char* name) {
416 strncpy(name_, name, sizeof(name_));
417 name_[sizeof(name_) - 1] = '\0';
418 }
419
420
409 void Thread::Start() { 421 void Thread::Start() {
410 pthread_create(&thread_handle_data()->thread_, NULL, ThreadEntry, this); 422 pthread_create(&thread_handle_data()->thread_, NULL, ThreadEntry, this);
411 ASSERT(IsValid()); 423 ASSERT(IsValid());
412 } 424 }
413 425
414 426
415 void Thread::Join() { 427 void Thread::Join() {
416 pthread_join(thread_handle_data()->thread_, NULL); 428 pthread_join(thread_handle_data()->thread_, NULL);
417 } 429 }
418 430
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 } 634 }
623 635
624 // This sampler is no longer the active sampler. 636 // This sampler is no longer the active sampler.
625 active_sampler_ = NULL; 637 active_sampler_ = NULL;
626 active_ = false; 638 active_ = false;
627 } 639 }
628 640
629 #endif // ENABLE_LOGGING_AND_PROFILING 641 #endif // ENABLE_LOGGING_AND_PROFILING
630 642
631 } } // namespace v8::internal 643 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-nullos.cc ('k') | src/platform-solaris.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698