Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(904)

Unified Diff: base/threading/simple_thread.cc

Issue 2218983003: Force non-joinable SimpleThreads to be leaked. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@f1_eatsecondparam_expectdcheckdeath
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/threading/simple_thread.cc
diff --git a/base/threading/simple_thread.cc b/base/threading/simple_thread.cc
index fa1a3449e057e2176244b092ab9b20b4ef88ba8e..0a0665631a2b14341ea277280fe6a46834d4253f 100644
--- a/base/threading/simple_thread.cc
+++ b/base/threading/simple_thread.cc
@@ -23,9 +23,10 @@ SimpleThread::SimpleThread(const std::string& name_prefix,
WaitableEvent::InitialState::NOT_SIGNALED) {}
SimpleThread::~SimpleThread() {
+ DCHECK(options_.joinable) << "A non-joinable thread must be leaked.";
DCHECK(HasBeenStarted()) << "SimpleThread was never started.";
- DCHECK(thread_.is_null()) << "Joinable SimpleThread destroyed without being "
- << "Join()ed.";
+ DCHECK(HasBeenJoined()) << "Joinable SimpleThread destroyed without being "
+ << "Join()ed.";
}
void SimpleThread::Start() {
@@ -41,9 +42,9 @@ void SimpleThread::Start() {
}
void SimpleThread::Join() {
+ DCHECK(options_.joinable) << "A non-joinable thread can't be joined.";
DCHECK(HasBeenStarted()) << "Tried to Join a never-started thread.";
DCHECK(!HasBeenJoined()) << "Tried to Join a thread multiple times.";
- DCHECK(!thread_.is_null()) << "A non-joinable thread can't be joined.";
PlatformThread::Join(thread_);
thread_ = PlatformThreadHandle();
joined_ = true;

Powered by Google App Engine
This is Rietveld 408576698