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

Unified Diff: base/threading/thread.h

Issue 1140363002: Revert of Reland: Lazily initialize MessageLoop for faster thread startup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « base/threading/platform_thread_win.cc ('k') | base/threading/thread.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/thread.h
diff --git a/base/threading/thread.h b/base/threading/thread.h
index 6b2f1c5169a7685bd8c5084ed4faa583bb73fbe3..49156063929759f62cab534432251947df10dec8 100644
--- a/base/threading/thread.h
+++ b/base/threading/thread.h
@@ -13,13 +13,11 @@
#include "base/message_loop/message_loop.h"
#include "base/message_loop/timer_slack.h"
#include "base/single_thread_task_runner.h"
-#include "base/synchronization/lock.h"
#include "base/threading/platform_thread.h"
namespace base {
class MessagePump;
-class WaitableEvent;
// A simple thread abstraction that establishes a MessageLoop on a new thread.
// The consumer uses the MessageLoop of the thread to cause code to execute on
@@ -47,7 +45,7 @@
// This is ignored if message_pump_factory.is_null() is false.
MessageLoop::Type message_loop_type;
- // Specifies timer slack for thread message loop.
+ // Specify timer slack for thread message loop.
TimerSlack timer_slack;
// Used to create the MessagePump for the MessageLoop. The callback is Run()
@@ -83,7 +81,7 @@
// init_com_with_mta(false) and then StartWithOptions() with any message loop
// type other than TYPE_UI.
void init_com_with_mta(bool use_mta) {
- DCHECK(!start_event_);
+ DCHECK(!started_);
com_status_ = use_mta ? MTA : STA;
}
#endif
@@ -104,18 +102,6 @@
// i.e. during a DllMain, global object construction or destruction, atexit()
// callback.
bool StartWithOptions(const Options& options);
-
- // Starts the thread and wait for the thread to start and run initialization
- // before returning. It's same as calling Start() and then
- // WaitUntilThreadStarted().
- // Note that using this (instead of Start() or StartWithOptions() causes
- // jank on the calling thread, should be used only in testing code.
- bool StartAndWaitForTesting();
-
- // Blocks until the thread starts running. Called within StartAndWait().
- // Note that calling this causes jank on the calling thread, must be used
- // carefully for production code.
- bool WaitUntilThreadStarted();
// 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
@@ -180,7 +166,7 @@
PlatformThreadHandle thread_handle() { return thread_; }
// The thread ID.
- PlatformThreadId thread_id() const;
+ PlatformThreadId thread_id() const { return thread_id_; }
// Returns true if the thread has been started, and not yet stopped.
bool IsRunning() const;
@@ -222,32 +208,33 @@
ComStatus com_status_;
#endif
+ // Whether we successfully started the thread.
+ bool started_;
+
// If true, we're in the middle of stopping, and shouldn't access
// |message_loop_|. It may non-NULL and invalid.
bool stopping_;
// True while inside of Run().
bool running_;
- mutable base::Lock running_lock_; // Protects running_.
+
+ // Used to pass data to ThreadMain.
+ struct StartupData;
+ StartupData* startup_data_;
// The thread's handle.
PlatformThreadHandle thread_;
- mutable base::Lock thread_lock_; // Protects thread_.
// The thread's message loop. Valid only while the thread is alive. Set
// by the created thread.
MessageLoop* message_loop_;
- // Stores Options::timer_slack_ until the message loop has been bound to
- // a thread.
- TimerSlack message_loop_timer_slack_;
+ // Our thread's ID.
+ PlatformThreadId thread_id_;
// The name of the thread. Used for debugging purposes.
std::string name_;
- // Non-null if the thread has successfully started.
- scoped_ptr<WaitableEvent> start_event_;
-
friend void ThreadQuitHelper();
DISALLOW_COPY_AND_ASSIGN(Thread);
« no previous file with comments | « base/threading/platform_thread_win.cc ('k') | base/threading/thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698