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

Unified Diff: base/message_loop/incoming_task_queue.h

Issue 1011683002: Lazily initialize MessageLoop for faster thread startup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: non-blocking thread_id() Created 5 years, 9 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 | « no previous file | base/message_loop/incoming_task_queue.cc » ('j') | base/message_loop/message_loop.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/incoming_task_queue.h
diff --git a/base/message_loop/incoming_task_queue.h b/base/message_loop/incoming_task_queue.h
index 72e1f30282966de72b01a505a6144839a1d00643..0d2d6b0058a2f2ae3bf946de123bb569d36e8f6d 100644
--- a/base/message_loop/incoming_task_queue.h
+++ b/base/message_loop/incoming_task_queue.h
@@ -26,6 +26,11 @@ class BASE_EXPORT IncomingTaskQueue
public:
explicit IncomingTaskQueue(MessageLoop* message_loop);
+ // Creates a task queue for the message loop that is to be initialized lazily
+ // (i.e. created by CreateForLazyInit()).
rvargas (doing something else) 2015/03/26 02:19:26 nit: try to keep cross-refs to a minimum (as in do
kinuko 2015/04/13 02:02:59 Done.
+ static IncomingTaskQueue* CreateForLazyInitMessageLoop(
rvargas (doing something else) 2015/03/26 02:19:26 return a scoped ptr (and same comment about this n
kinuko 2015/04/13 02:02:59 Done. (This is ref-counted so returning scoped_ref
+ MessageLoop* message_loop);
+
// Appends a task to the incoming queue. Posting of all tasks is routed though
// AddToIncomingQueue() or TryAddToIncomingQueue() to make sure that posting
// task is properly synchronized between different threads.
@@ -53,6 +58,13 @@ class BASE_EXPORT IncomingTaskQueue
// Disconnects |this| from the parent message loop.
void WillDestroyCurrentMessageLoop();
+ // Called when |message_loop_|'s LazyInit() is called, so that now it's ready
+ // for scheduling work. It is not valid to call this unless this task queue
+ // is created by CreateForLazyInitMessageLoop().
+ void DidInitializeMessageLoop();
rvargas (doing something else) 2015/03/26 02:19:26 Maybe StartScheduling() ?
kinuko 2015/04/13 02:02:59 Done.
+
+ bool empty();
rvargas (doing something else) 2015/03/26 02:19:26 nit: doc
kinuko 2015/04/13 02:02:59 Done.
+
private:
friend class RefCountedThreadSafe<IncomingTaskQueue>;
virtual ~IncomingTaskQueue();
@@ -92,6 +104,11 @@ class BASE_EXPORT IncomingTaskQueue
// if the incoming queue was not empty.
const bool always_schedule_work_;
+ // True if our message loop is created for lazy initialization and hasn't been
+ // initialized yet. Note that while this is true this task queue won't call
+ // ScheduleWork even if always_schedule_work_ is true.
+ bool message_loop_not_initialized_ = false;
+
DISALLOW_COPY_AND_ASSIGN(IncomingTaskQueue);
};
« no previous file with comments | « no previous file | base/message_loop/incoming_task_queue.cc » ('j') | base/message_loop/message_loop.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698