| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/base/platform/platform.h" | 5 #include "src/base/platform/platform.h" |
| 6 | 6 |
| 7 #if V8_OS_POSIX | 7 #if V8_OS_POSIX |
| 8 #include <unistd.h> // NOLINT | 8 #include <unistd.h> // NOLINT |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 #if V8_OS_WIN | 24 #if V8_OS_WIN |
| 25 EXPECT_EQ(static_cast<int>(::GetCurrentProcessId()), | 25 EXPECT_EQ(static_cast<int>(::GetCurrentProcessId()), |
| 26 OS::GetCurrentProcessId()); | 26 OS::GetCurrentProcessId()); |
| 27 #endif | 27 #endif |
| 28 } | 28 } |
| 29 | 29 |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 class SelfJoinThread V8_FINAL : public Thread { | 33 class SelfJoinThread FINAL : public Thread { |
| 34 public: | 34 public: |
| 35 SelfJoinThread() : Thread(Options("SelfJoinThread")) {} | 35 SelfJoinThread() : Thread(Options("SelfJoinThread")) {} |
| 36 virtual void Run() V8_OVERRIDE { Join(); } | 36 virtual void Run() OVERRIDE { Join(); } |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 | 41 |
| 42 TEST(Thread, SelfJoin) { | 42 TEST(Thread, SelfJoin) { |
| 43 SelfJoinThread thread; | 43 SelfJoinThread thread; |
| 44 thread.Start(); | 44 thread.Start(); |
| 45 thread.Join(); | 45 thread.Join(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 | 48 |
| 49 namespace { | 49 namespace { |
| 50 | 50 |
| 51 class ThreadLocalStorageTest : public Thread, public ::testing::Test { | 51 class ThreadLocalStorageTest : public Thread, public ::testing::Test { |
| 52 public: | 52 public: |
| 53 ThreadLocalStorageTest() : Thread(Options("ThreadLocalStorageTest")) { | 53 ThreadLocalStorageTest() : Thread(Options("ThreadLocalStorageTest")) { |
| 54 for (size_t i = 0; i < arraysize(keys_); ++i) { | 54 for (size_t i = 0; i < arraysize(keys_); ++i) { |
| 55 keys_[i] = Thread::CreateThreadLocalKey(); | 55 keys_[i] = Thread::CreateThreadLocalKey(); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 ~ThreadLocalStorageTest() { | 58 ~ThreadLocalStorageTest() { |
| 59 for (size_t i = 0; i < arraysize(keys_); ++i) { | 59 for (size_t i = 0; i < arraysize(keys_); ++i) { |
| 60 Thread::DeleteThreadLocalKey(keys_[i]); | 60 Thread::DeleteThreadLocalKey(keys_[i]); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 virtual void Run() V8_FINAL V8_OVERRIDE { | 64 virtual void Run() FINAL OVERRIDE { |
| 65 for (size_t i = 0; i < arraysize(keys_); i++) { | 65 for (size_t i = 0; i < arraysize(keys_); i++) { |
| 66 CHECK(!Thread::HasThreadLocal(keys_[i])); | 66 CHECK(!Thread::HasThreadLocal(keys_[i])); |
| 67 } | 67 } |
| 68 for (size_t i = 0; i < arraysize(keys_); i++) { | 68 for (size_t i = 0; i < arraysize(keys_); i++) { |
| 69 Thread::SetThreadLocal(keys_[i], GetValue(i)); | 69 Thread::SetThreadLocal(keys_[i], GetValue(i)); |
| 70 } | 70 } |
| 71 for (size_t i = 0; i < arraysize(keys_); i++) { | 71 for (size_t i = 0; i < arraysize(keys_); i++) { |
| 72 CHECK(Thread::HasThreadLocal(keys_[i])); | 72 CHECK(Thread::HasThreadLocal(keys_[i])); |
| 73 } | 73 } |
| 74 for (size_t i = 0; i < arraysize(keys_); i++) { | 74 for (size_t i = 0; i < arraysize(keys_); i++) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 101 | 101 |
| 102 | 102 |
| 103 TEST_F(ThreadLocalStorageTest, DoTest) { | 103 TEST_F(ThreadLocalStorageTest, DoTest) { |
| 104 Run(); | 104 Run(); |
| 105 Start(); | 105 Start(); |
| 106 Join(); | 106 Join(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace base | 109 } // namespace base |
| 110 } // namespace v8 | 110 } // namespace v8 |
| OLD | NEW |