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

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

Issue 6577036: [Isolates] Merge from bleeding_edge to isolates, revisions 6100-6300. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 9 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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(Isolate* isolate) 389 Thread::Thread(Isolate* isolate)
390 : ThreadHandle(ThreadHandle::INVALID), 390 : ThreadHandle(ThreadHandle::INVALID),
391 isolate_(isolate) { 391 isolate_(isolate) {
392 set_name("v8:<unknown>");
393 }
394
395
396 Thread::Thread(Isolate* isolate, const char* name)
397 : ThreadHandle(ThreadHandle::INVALID),
398 isolate_(isolate) {
399 set_name(name);
392 } 400 }
393 401
394 402
395 Thread::~Thread() { 403 Thread::~Thread() {
396 } 404 }
397 405
398 406
399 static void* ThreadEntry(void* arg) { 407 static void* ThreadEntry(void* arg) {
400 Thread* thread = reinterpret_cast<Thread*>(arg); 408 Thread* thread = reinterpret_cast<Thread*>(arg);
401 // This is also initialized by the first argument to pthread_create() but we 409 // This is also initialized by the first argument to pthread_create() but we
402 // don't know which thread will run first (the original thread or the new 410 // don't know which thread will run first (the original thread or the new
403 // one) so we initialize it here too. 411 // one) so we initialize it here too.
404 thread->thread_handle_data()->thread_ = pthread_self(); 412 thread->thread_handle_data()->thread_ = pthread_self();
405 ASSERT(thread->IsValid()); 413 ASSERT(thread->IsValid());
406 Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate()); 414 Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate());
407 thread->Run(); 415 thread->Run();
408 return NULL; 416 return NULL;
409 } 417 }
410 418
411 419
420 void Thread::set_name(const char* name) {
421 strncpy(name_, name, sizeof(name_));
422 name_[sizeof(name_) - 1] = '\0';
423 }
424
425
412 void Thread::Start() { 426 void Thread::Start() {
413 pthread_create(&thread_handle_data()->thread_, NULL, ThreadEntry, this); 427 pthread_create(&thread_handle_data()->thread_, NULL, ThreadEntry, this);
414 ASSERT(IsValid()); 428 ASSERT(IsValid());
415 } 429 }
416 430
417 431
418 void Thread::Join() { 432 void Thread::Join() {
419 pthread_join(thread_handle_data()->thread_, NULL); 433 pthread_join(thread_handle_data()->thread_, NULL);
420 } 434 }
421 435
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 } 640 }
627 641
628 // This sampler is no longer the active sampler. 642 // This sampler is no longer the active sampler.
629 active_sampler_ = NULL; 643 active_sampler_ = NULL;
630 active_ = false; 644 active_ = false;
631 } 645 }
632 646
633 #endif // ENABLE_LOGGING_AND_PROFILING 647 #endif // ENABLE_LOGGING_AND_PROFILING
634 648
635 } } // namespace v8::internal 649 } } // 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