| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium 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 "mojo/public/cpp/utility/thread.h" | 5 #include "mojo/public/cpp/utility/thread.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "mojo/public/cpp/system/macros.h" | 9 #include "mojo/public/cpp/system/macros.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 } | 25 } |
| 26 | 26 |
| 27 ~SetIntThread() override {} | 27 ~SetIntThread() override {} |
| 28 | 28 |
| 29 void Run() override { *int_to_set_ = value_; } | 29 void Run() override { *int_to_set_ = value_; } |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 int* const int_to_set_; | 32 int* const int_to_set_; |
| 33 const int value_; | 33 const int value_; |
| 34 | 34 |
| 35 MOJO_DISALLOW_COPY_AND_ASSIGN(SetIntThread); | 35 DISALLOW_COPY_AND_ASSIGN(SetIntThread); |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 TEST(ThreadTest, CreateAndJoin) { | 38 TEST(ThreadTest, CreateAndJoin) { |
| 39 int value = 0; | 39 int value = 0; |
| 40 | 40 |
| 41 // Not starting the thread should result in a no-op. | 41 // Not starting the thread should result in a no-op. |
| 42 { | 42 { |
| 43 SetIntThread thread(&value, 1234567); | 43 SetIntThread thread(&value, 1234567); |
| 44 } | 44 } |
| 45 EXPECT_EQ(0, value); | 45 EXPECT_EQ(0, value); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 options.set_stack_size(static_cast<size_t>(-1)); | 99 options.set_stack_size(static_cast<size_t>(-1)); |
| 100 SetIntThread thread(options, &value, 4); | 100 SetIntThread thread(options, &value, 4); |
| 101 thread.Start(); | 101 thread.Start(); |
| 102 thread.Join(); | 102 thread.Join(); |
| 103 }, ""); | 103 }, ""); |
| 104 } | 104 } |
| 105 #endif // !defined(NDEBUG) | 105 #endif // !defined(NDEBUG) |
| 106 | 106 |
| 107 } // namespace | 107 } // namespace |
| 108 } // namespace mojo | 108 } // namespace mojo |
| OLD | NEW |