diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-03 00:30:47 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-03 00:30:47 +0000 |
commit | c7cdaeb9549c38d91a885c1e1045c536354d8911 (patch) | |
tree | 8616f889dfa3e84da7ba80e92b3b0cdeece5f31a /base/threading/thread.h | |
parent | c6464ad8b064fb8883c37b9eb3f20533f47a2aeb (diff) | |
download | chromium_src-c7cdaeb9549c38d91a885c1e1045c536354d8911.zip chromium_src-c7cdaeb9549c38d91a885c1e1045c536354d8911.tar.gz chromium_src-c7cdaeb9549c38d91a885c1e1045c536354d8911.tar.bz2 |
Call Stop() from all destructors of base::Thread subclasses (except for a couple that ensure Stop() has already been called).
BUG=none
TEST=none
TBR=willchan,hans
Review URL: https://codereview.chromium.org/11026019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159812 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/threading/thread.h')
-rw-r--r-- | base/threading/thread.h | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/base/threading/thread.h b/base/threading/thread.h index 7296854..1d24cf3 100644 --- a/base/threading/thread.h +++ b/base/threading/thread.h @@ -20,7 +20,7 @@ namespace base { // pending tasks queued on the thread's message loop will run to completion // before the thread is terminated. // -// NOTE: Subclasses must call Stop() in their destructor. See ~Thread below. +// WARNING! SUBCLASSES MUST CALL Stop() IN THEIR DESTRUCTORS! See ~Thread(). // // After the thread is stopped, the destruction sequence is: // @@ -49,13 +49,12 @@ class BASE_EXPORT Thread : PlatformThread::Delegate { // Destroys the thread, stopping it if necessary. // - // NOTE: All subclasses of Thread must call Stop() in their - // destructor, or otherwise ensure Stop() is called before the - // subclass is destructed. This is required to avoid a data race - // between the destructor modifying the vtable, and the thread's - // ThreadMain calling the virtual method Run. It also ensures that - // the CleanUp() virtual method is called on the subclass before it - // is destructed. + // NOTE: ALL SUBCLASSES OF Thread MUST CALL Stop() IN THEIR DESTRUCTORS (or + // guarantee Stop() is explicitly called before the subclass is destroyed). + // This is required to avoid a data race between the destructor modifying the + // vtable, and the thread's ThreadMain calling the virtual method Run(). It + // also ensures that the CleanUp() virtual method is called on the subclass + // before it is destructed. virtual ~Thread(); // Starts the thread. Returns true if the thread was successfully started; @@ -82,10 +81,9 @@ class BASE_EXPORT Thread : PlatformThread::Delegate { // Stop may be called multiple times and is simply ignored if the thread is // already stopped. // - // NOTE: This method is optional. It is not strictly necessary to call this - // method as the Thread's destructor will take care of stopping the thread if - // necessary. - // + // 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. + // IF YOU ARE A SUBCLASS OF Thread, YOU MUST CALL THIS IN YOUR DESTRUCTOR. void Stop(); // Signals the thread to exit in the near future. |