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

Unified Diff: base/threading/thread.h

Issue 2135413003: Add |joinable| to Thread::Options (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self-review Created 4 years, 5 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/thread.h
diff --git a/base/threading/thread.h b/base/threading/thread.h
index 720ba8b6be80755e4ea833c1cd18d9f7193bbed2..e15a243b1b022586a162886187a32290e498f7a9 100644
--- a/base/threading/thread.h
+++ b/base/threading/thread.h
@@ -74,6 +74,12 @@ class BASE_EXPORT Thread : PlatformThread::Delegate {
// Specifies the initial thread priority.
ThreadPriority priority = ThreadPriority::NORMAL;
+
+ // If false, the thread will not be joined on destruction. This is intended
+ // for threads that want TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN
+ // semantics. Stop() will not be synchronous and will instead merely have
+ // StopSoon() semantics on such threads.
+ bool joinable = true;
};
// Constructor.
@@ -131,12 +137,14 @@ class BASE_EXPORT Thread : PlatformThread::Delegate {
// carefully for production code.
bool WaitUntilThreadStarted() const;
- // Signals the thread to exit and returns once the thread has exited. After
- // this method returns, the Thread object is completely reset and may be used
- // as if it were newly constructed (i.e., Start may be called again).
+ // Signals the thread to exit and returns once the thread has exited (or right
danakj 2016/07/22 21:00:40 A thought: what if we made it illegal to call Stop
gab 2016/07/25 16:07:40 That was my first instinct too, but then I realize
+ // away if the thread is non-joinable). For joinable threads only: after this
+ // method returns, the Thread object is completely reset and may be used as if
+ // it were newly constructed (i.e., Start may be called again) -- non-joinable
+ // threads are not re-usable.
//
// Stop may be called multiple times and is simply ignored if the thread is
- // already stopped.
+ // already stopped or currently stopping.
//
// NOTE: If you are a consumer of Thread, it is not necessary to call this
// before deleting your Thread objects, as the destructor will do it.

Powered by Google App Engine
This is Rietveld 408576698