Commit 143a68be authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Always initialize SimpleThreadImpl::thread_manager_

SimpleThreadImpl::thread_manager_ is initialized in its thread's Run
function which means that it is racy in relationship to the use. This
change doesn't fix the raciness but it does initialize thread_manager_
to nullptr in the class declaration which is a good practice. Fixing the
code to not use SimpleThreadImpl until Run() has completed the
initialization is left for the owner.

Bug: 897872
Change-Id: I50d38f10d4297334ae02698ecd43a0fbf44db374
Reviewed-on: https://chromium-review.googlesource.com/c/1316657Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Commit-Queue: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605305}
parent 18bf5948
......@@ -36,7 +36,7 @@ class PLATFORM_EXPORT SimpleThreadImpl : public SimpleThread {
void Run() override;
// Owner of this class.
ThreadPoolManager* thread_pool_manager_;
ThreadPoolManager* thread_pool_manager_ = nullptr;
// Time in which the thread is created.
TimeTicks initial_time_;
......@@ -44,7 +44,7 @@ class PLATFORM_EXPORT SimpleThreadImpl : public SimpleThread {
// The object pointed to by |thread_manager_| is created and destructed from
// the Run function. This is necessary since it has to be constructed from the
// thread it should be bound to and destructed from the same thread.
ThreadManager* thread_manager_;
ThreadManager* thread_manager_ = nullptr;
// Used by the Run function to only terminate when |this| is destructed, and
// this is used so that |thread_data_| will live as long as |this|.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment