OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This module contains the platform-specific code. This make the rest of the | 5 // This module contains the platform-specific code. This make the rest of the |
6 // code less dependent on operating system, compilers and runtime libraries. | 6 // code less dependent on operating system, compilers and runtime libraries. |
7 // This module does specifically not deal with differences between different | 7 // This module does specifically not deal with differences between different |
8 // processor architecture. | 8 // processor architecture. |
9 // The platform classes have the same definition for all platforms. The | 9 // The platform classes have the same definition for all platforms. The |
10 // implementation for a particular platform is put in platform_<os>.cc. | 10 // implementation for a particular platform is put in platform_<os>.cc. |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 InternalGetExistingThreadLocal(static_cast<intptr_t>(key))); | 439 InternalGetExistingThreadLocal(static_cast<intptr_t>(key))); |
440 DCHECK(result == GetThreadLocal(key)); | 440 DCHECK(result == GetThreadLocal(key)); |
441 return result; | 441 return result; |
442 } | 442 } |
443 #else | 443 #else |
444 static inline void* GetExistingThreadLocal(LocalStorageKey key) { | 444 static inline void* GetExistingThreadLocal(LocalStorageKey key) { |
445 return GetThreadLocal(key); | 445 return GetThreadLocal(key); |
446 } | 446 } |
447 #endif | 447 #endif |
448 | 448 |
449 // A hint to the scheduler to let another thread run. | |
450 static void YieldCPU(); | |
451 | |
452 | |
453 // The thread name length is limited to 16 based on Linux's implementation of | 449 // The thread name length is limited to 16 based on Linux's implementation of |
454 // prctl(). | 450 // prctl(). |
455 static const int kMaxThreadNameLength = 16; | 451 static const int kMaxThreadNameLength = 16; |
456 | 452 |
457 class PlatformData; | 453 class PlatformData; |
458 PlatformData* data() { return data_; } | 454 PlatformData* data() { return data_; } |
459 | 455 |
460 void NotifyStartedAndRun() { | 456 void NotifyStartedAndRun() { |
461 if (start_semaphore_) start_semaphore_->Signal(); | 457 if (start_semaphore_) start_semaphore_->Signal(); |
462 Run(); | 458 Run(); |
463 } | 459 } |
464 | 460 |
465 private: | 461 private: |
466 void set_name(const char* name); | 462 void set_name(const char* name); |
467 | 463 |
468 PlatformData* data_; | 464 PlatformData* data_; |
469 | 465 |
470 char name_[kMaxThreadNameLength]; | 466 char name_[kMaxThreadNameLength]; |
471 int stack_size_; | 467 int stack_size_; |
472 Semaphore* start_semaphore_; | 468 Semaphore* start_semaphore_; |
473 | 469 |
474 DISALLOW_COPY_AND_ASSIGN(Thread); | 470 DISALLOW_COPY_AND_ASSIGN(Thread); |
475 }; | 471 }; |
476 | 472 |
477 } } // namespace v8::base | 473 } } // namespace v8::base |
478 | 474 |
479 #endif // V8_BASE_PLATFORM_PLATFORM_H_ | 475 #endif // V8_BASE_PLATFORM_PLATFORM_H_ |
OLD | NEW |