| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/test/gtest_util.h" | 10 #include "base/test/gtest_util.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 std::string("event_waiter/") + IntToString(thread.tid())); | 146 std::string("event_waiter/") + IntToString(thread.tid())); |
| 147 } | 147 } |
| 148 | 148 |
| 149 TEST(SimpleThreadTest, JoinNonJoinableThreadDeath) { | 149 TEST(SimpleThreadTest, JoinNonJoinableThreadDeath) { |
| 150 SleepRunner runner; | 150 SleepRunner runner; |
| 151 SimpleThread::Options options; | 151 SimpleThread::Options options; |
| 152 options.joinable = false; | 152 options.joinable = false; |
| 153 DelegateSimpleThread thread(&runner, "noop_runner", options); | 153 DelegateSimpleThread thread(&runner, "noop_runner", options); |
| 154 | 154 |
| 155 thread.Start(); | 155 thread.Start(); |
| 156 EXPECT_DCHECK_DEATH(thread.Join(), ""); | 156 EXPECT_DCHECK_DEATH(thread.Join()); |
| 157 } | 157 } |
| 158 | 158 |
| 159 TEST(SimpleThreadTest, DeleteNonJoinableWithoutJoinIsSafe) { | 159 TEST(SimpleThreadTest, DeleteNonJoinableWithoutJoinIsSafe) { |
| 160 SleepRunner runner; | 160 SleepRunner runner; |
| 161 SimpleThread::Options options; | 161 SimpleThread::Options options; |
| 162 options.joinable = false; | 162 options.joinable = false; |
| 163 DelegateSimpleThread thread(&runner, "noop_runner", options); | 163 DelegateSimpleThread thread(&runner, "noop_runner", options); |
| 164 thread.Start(); | 164 thread.Start(); |
| 165 // Nothing blows up when |thread| goes out of scope. | 165 // Nothing blows up when |thread| goes out of scope. |
| 166 } | 166 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 192 VerifyPoolRunner verifier(&seq2, 9, &event); | 192 VerifyPoolRunner verifier(&seq2, 9, &event); |
| 193 pool.Start(); | 193 pool.Start(); |
| 194 | 194 |
| 195 pool.AddWork(&verifier, 10); | 195 pool.AddWork(&verifier, 10); |
| 196 | 196 |
| 197 pool.JoinAll(); | 197 pool.JoinAll(); |
| 198 EXPECT_EQ(seq2.GetNext(), 10); | 198 EXPECT_EQ(seq2.GetNext(), 10); |
| 199 } | 199 } |
| 200 | 200 |
| 201 } // namespace base | 201 } // namespace base |
| OLD | NEW |