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

Side by Side Diff: src/platform-solaris.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-openbsd.cc ('k') | src/platform-win32.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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 return pthread_equal(data_->thread_, pthread_self()); 394 return pthread_equal(data_->thread_, pthread_self());
395 } 395 }
396 396
397 397
398 bool ThreadHandle::IsValid() const { 398 bool ThreadHandle::IsValid() const {
399 return data_->thread_ != kNoThread; 399 return data_->thread_ != kNoThread;
400 } 400 }
401 401
402 402
403 Thread::Thread() : ThreadHandle(ThreadHandle::INVALID) { 403 Thread::Thread() : ThreadHandle(ThreadHandle::INVALID) {
404 set_name("v8:<unknown>");
405 }
406
407
408 Thread::Thread(const char* name) : ThreadHandle(ThreadHandle::INVALID) {
409 set_name(name);
404 } 410 }
405 411
406 412
407 Thread::~Thread() { 413 Thread::~Thread() {
408 } 414 }
409 415
410 416
411 static void* ThreadEntry(void* arg) { 417 static void* ThreadEntry(void* arg) {
412 Thread* thread = reinterpret_cast<Thread*>(arg); 418 Thread* thread = reinterpret_cast<Thread*>(arg);
413 // This is also initialized by the first argument to pthread_create() but we 419 // This is also initialized by the first argument to pthread_create() but we
414 // don't know which thread will run first (the original thread or the new 420 // don't know which thread will run first (the original thread or the new
415 // one) so we initialize it here too. 421 // one) so we initialize it here too.
416 thread->thread_handle_data()->thread_ = pthread_self(); 422 thread->thread_handle_data()->thread_ = pthread_self();
417 ASSERT(thread->IsValid()); 423 ASSERT(thread->IsValid());
418 thread->Run(); 424 thread->Run();
419 return NULL; 425 return NULL;
420 } 426 }
421 427
422 428
429 void Thread::set_name(const char* name) {
430 strncpy(name_, name, sizeof(name_));
431 name_[sizeof(name_) - 1] = '\0';
432 }
433
434
423 void Thread::Start() { 435 void Thread::Start() {
424 pthread_create(&thread_handle_data()->thread_, NULL, ThreadEntry, this); 436 pthread_create(&thread_handle_data()->thread_, NULL, ThreadEntry, this);
425 ASSERT(IsValid()); 437 ASSERT(IsValid());
426 } 438 }
427 439
428 440
429 void Thread::Join() { 441 void Thread::Join() {
430 pthread_join(thread_handle_data()->thread_, NULL); 442 pthread_join(thread_handle_data()->thread_, NULL);
431 } 443 }
432 444
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 } 664 }
653 665
654 // This sampler is no longer the active sampler. 666 // This sampler is no longer the active sampler.
655 active_sampler_ = NULL; 667 active_sampler_ = NULL;
656 active_ = false; 668 active_ = false;
657 } 669 }
658 670
659 #endif // ENABLE_LOGGING_AND_PROFILING 671 #endif // ENABLE_LOGGING_AND_PROFILING
660 672
661 } } // namespace v8::internal 673 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-openbsd.cc ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698