 Chromium Code Reviews
 Chromium Code Reviews Issue 2218983003:
  Force non-joinable SimpleThreads to be leaked.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@f1_eatsecondparam_expectdcheckdeath
    
  
    Issue 2218983003:
  Force non-joinable SimpleThreads to be leaked.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@f1_eatsecondparam_expectdcheckdeath| Index: base/threading/simple_thread_unittest.cc | 
| diff --git a/base/threading/simple_thread_unittest.cc b/base/threading/simple_thread_unittest.cc | 
| index 26e3a907bc7b5faed77525e59f0a758fabc0472f..8b197a89238f728d7d83f1e1986b9d3f7f9982d8 100644 | 
| --- a/base/threading/simple_thread_unittest.cc | 
| +++ b/base/threading/simple_thread_unittest.cc | 
| @@ -5,6 +5,7 @@ | 
| #include <memory> | 
| #include "base/atomic_sequence_num.h" | 
| +#include "base/debug/leak_annotations.h" | 
| #include "base/strings/string_number_conversions.h" | 
| #include "base/synchronization/waitable_event.h" | 
| #include "base/test/gtest_util.h" | 
| @@ -146,23 +147,34 @@ TEST(SimpleThreadTest, NamedWithOptions) { | 
| std::string("event_waiter/") + IntToString(thread.tid())); | 
| } | 
| -TEST(SimpleThreadTest, JoinNonJoinableThreadDeath) { | 
| +TEST(SimpleThreadTest, StartNonJoinableThreadAndDieOnJoin) { | 
| SleepRunner runner; | 
| 
sdefresne
2016/08/05 16:48:33
I think SleepRunner also needs to be leaked as Del
 
gab
2016/08/05 17:28:33
Good point, for DelegateSimpleThread, the Delegate
 | 
| + | 
| SimpleThread::Options options; | 
| options.joinable = false; | 
| - DelegateSimpleThread thread(&runner, "noop_runner", options); | 
| + DelegateSimpleThread* thread = | 
| + new DelegateSimpleThread(&runner, "noop_runner", options); | 
| + // Non-joinable SimpleThreads have to be leaked. | 
| + ANNOTATE_LEAKING_OBJECT_PTR(thread); | 
| - thread.Start(); | 
| - EXPECT_DCHECK_DEATH(thread.Join()); | 
| + EXPECT_FALSE(thread->HasBeenStarted()); | 
| + thread->Start(); | 
| + EXPECT_TRUE(thread->HasBeenStarted()); | 
| + EXPECT_FALSE(thread->HasBeenJoined()); | 
| + | 
| + EXPECT_DCHECK_DEATH(thread->Join()); | 
| } | 
| -TEST(SimpleThreadTest, DeleteNonJoinableWithoutJoinIsSafe) { | 
| +TEST(SimpleThreadTest, NonJoinableThreadDeathOnDestruction) { | 
| SleepRunner runner; | 
| SimpleThread::Options options; | 
| options.joinable = false; | 
| - DelegateSimpleThread thread(&runner, "noop_runner", options); | 
| - thread.Start(); | 
| - // Nothing blows up when |thread| goes out of scope. | 
| + DelegateSimpleThread* thread = | 
| + new DelegateSimpleThread(&runner, "noop_runner", options); | 
| + ANNOTATE_LEAKING_OBJECT_PTR(thread); | 
| + | 
| + thread->Start(); | 
| + EXPECT_DCHECK_DEATH({ delete thread; }); | 
| } | 
| TEST(SimpleThreadTest, ThreadPool) { |