FYI, the current replacements are about to be applied to the codebase:
Before | After |
MessageLoop::current()-> PostTask PostDelayedTask DeleteSoon ReleaseSoon | ThreadTaskRunnerHandle::Get()-> PostTask PostDelayedTask DeleteSoon ReleaseSoon |
MessageLoop::current()->task_runner() | ThreadTaskRunnerHandle::Get() |
MessageLoop::current()->Run() | RunLoop.Run() |
These replacements don’t change code behavior.
Why is this happening?
The fact that there's a MessageLoop on the thread is an unnecessary implementation detail. When browser threads are migrated to base/task_scheduler [1], tasks will no longer have access to a MessageLoop.
MessageLoop::PostTask/PostDelayedTask/DeleteSoon/ReleaseSoon/Run are deprecated.
Follow progress: https://crbug.com/616447
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
Calls to MessageLoopForUI::current()->PostTask/PostDelayedTask/DeleteSoon/ReleaseSoon have to be migrated because they are deprecated. However, since the UI thread won’t be migrated to base/task_scheduler in the near future, reviewers can ask me to migrate these calls to MessageLoopForUI::current()->task_runner()->PostTask/… instead of ThreadTaskRunnerHandle::Get()->PostTask/...
Calls to MessageLoopForIO::current()->PostTask/… also have to be migrated because they are deprecated. Before threads running a MessageLoopForIO are migrated to base/task_scheduler, we will introduce an async I/O API that can be used from any thread (work in progress). Therefore, there will be no reason to check that the current thread supports async I/O.
To verify that tasks don’t run at the same time (thread safety):
To verify that tasks run on the same thread (thread affinity):
To verify that a task runs on a given named thread:
Code that cannot access DCHECK_CURRENTLY_ON() shouldn’t know about Chrome threads, except maybe about the UI thread. DCHECK(MessageLoopForUI::IsCurrent() can be used to verify that code runs on the UI thread, but it is misleading because there are other threads running MessageLoopForUI.