[MessageLoop] Refactor ScheduleWork and TaskAnnotator logic out of IncomingTaskQueue
This was extracted from https://chromium-review.googlesource.com/c/chromium/src/+/1088762/17 in an attempt to simplify it (and is now a precursor to it). (MessageLoop::Controller was IncomingTaskQueue::MessageLoopController there but after grokking the resulting CL it's simpler under MessageLoop as done in this CL) This CL splits the logic in IncomingTaskQueue which took care of scheduling the MessageLoop into a dedicated class. In that follow-up CL: MessageLoopTaskRunner will interact directly with the task Observer and take IncomingTaskQueue completely out of the picture (merely a data structure holding various task queues at that point). IncomingTaskQueue also took care of detaching on MessageLoop shutdown which was moved to the new Controller class as well. message_loop.cc is the best place for this extracted logic as it all pertains precisely to MessageLoop's implementation detail (how ScheduleWork should be invoked). This CL simplifies locking as well by having a clear separation between the two locks instead of two locks in the same class used interchangibly. |incoming_queue_lock_| is now strictly for incoming tasks. |message_loop_lock_| is now strictly for ScheduleWork()/DisconnectFromParent(). Note: |message_loop_scheduled_| was dropped as it was redundant (always equal to |!was_empty|). Performance wise, the perf tests show that this change is a noop : * While BasicPostTaskPerfTest became simpler (executed less code) with this CL : The new BasicPostTaskPerfTest w/ MockObserverSimulatingOverhead reintroduces that overhead to show that it's still the same (or slightly in favor of this CL). * And the IntegratedPostTaskPerfTest are the same. * Augmented perf tests to 30 seconds which yields more reliable results. (and ran old ones under 30s mode too when comparing) * Results : https://docs.google.com/spreadsheets/d/100wYvbCI_dJ7gRnQiSsYaTb5OJnbF_muL6LyQWJLXSU/edit Bug: 860252 Change-Id: I22de2409d52414524cc125b0e2fe08e2c516fcbe Reviewed-on: https://chromium-review.googlesource.com/1127262 Commit-Queue: Gabriel Charette <gab@chromium.org> Reviewed-by:danakj <danakj@chromium.org> Reviewed-by:
kylechar <kylechar@chromium.org> Cr-Commit-Position: refs/heads/master@{#574048}
Showing
Please register or sign in to comment