gecko-dev/xpcom/threads
Nika Layzell 3e323b7d7a Bug 1739727 - Part 2: Improve rust async support in moz_task, r=emilio
This patch contains changes to moz_task to improve it's support for
async execution on multiple threads. Unlike the previous executor
implementation, this new implementation reduces the amount of unsafe
code substantially by depending on the async-task crate
(https://crates.io/crates/async-task) for the core task implementation.
This adds a few additional features:

 * Both local (no Send bound) and non-local (with Send bound) execution support,
 * Support for spawning on arbitrary nsIEventTargets or the background task pool,
 * Returned Task objects from runnables which may be .await-ed on or detach()-ed,
 * Support for spawning with the NS_DISPATCH_EVENT_MAY_BLOCK flag set,
 * Automatic use of NS_DISPATCH_AT_END when required,
 * Support for specifying the runnable priority for runnables.

There are also some correctness improvements, and exposed a better API
for dispatching normal runnable functions to background threads.

After these changes the TaskRunnable API should no longer be necessary.
It is re-implemented on top of the executor and kept in-place to avoid
rewriting all consumers.

Differential Revision: https://phabricator.services.mozilla.com/D130705
2021-12-07 20:01:41 +00:00
..
AbstractThread.cpp Bug 1695580 - In xpcom, cancel pending DelayedRunnable timers on shutdown. r=KrisWright 2021-04-06 20:15:11 +00:00
AbstractThread.h Bug 1724867 - Allow using IsOnCurrentThread on AbstractThread. r=xpcom-reviewers,nika 2021-08-10 08:04:49 +00:00
BlockingResourceBase.cpp Bug 1727563 - Implement TryLock methods and RAII helpers for RWLock. r=xpcom-reviewers,nika 2021-09-08 10:40:07 +00:00
BlockingResourceBase.h Bug 1515229 - Make MozStackWalk/MozWalkTheStack frame skipping more reliable. r=gerald,nika,bobowen,jld 2021-04-16 04:06:02 +00:00
CPUUsageWatcher.cpp Bug 1733308 - Fix non-unified builds errors in xpcom/threads. r=xpcom-reviewers,mccr8 2021-10-01 01:49:18 +00:00
CPUUsageWatcher.h
CondVar.h
DataMutex.h
DeadlockDetector.h Bug 1184468 - Use nsBaseHashtable::Values. r=xpcom-reviewers,nika 2021-03-24 17:56:49 +00:00
DelayedRunnable.cpp Bug 1695580 - In xpcom, cancel pending DelayedRunnable timers on shutdown. r=KrisWright 2021-04-06 20:15:11 +00:00
DelayedRunnable.h Bug 1695580 - In xpcom, cancel pending DelayedRunnable timers on shutdown. r=KrisWright 2021-04-06 20:15:11 +00:00
EventQueue.cpp Bug 1738627 - Store distinct profiling features of individual threads - r=canaltinova 2021-11-08 23:59:35 +00:00
EventQueue.h Bug 1734809 - add a new task priority between vsync and control, r=bas 2021-10-08 19:29:36 +00:00
IdlePeriodState.cpp Bug 1683031 - pt 5. Add an assertion and document idle request IDs r=smaug 2020-12-22 17:56:46 +00:00
IdlePeriodState.h Bug 1713320, ensure idle tasks get run, r=bas 2021-05-31 13:32:36 +00:00
IdleTaskRunner.cpp Backed out 5 changesets (bug 1672121) for various crashes on mozalloc_handle_oom. CLOSED TREE 2021-11-30 02:59:20 +02:00
IdleTaskRunner.h Backed out 5 changesets (bug 1672121) for various crashes on mozalloc_handle_oom. CLOSED TREE 2021-11-30 02:59:20 +02:00
InputEventStatistics.cpp Bug 1733308 - Fix non-unified builds errors in xpcom/threads. r=xpcom-reviewers,mccr8 2021-10-01 01:49:18 +00:00
InputEventStatistics.h Bug 1697585 - Make input tasks can be more strictly aligned with Vsync r=smaug 2021-04-14 19:56:42 +00:00
InputTaskManager.cpp Bug 1733308 - Fix non-unified builds errors in xpcom/threads. r=xpcom-reviewers,mccr8 2021-10-01 01:49:18 +00:00
InputTaskManager.h Bug 1733729: Fix non-unified build bustage in xpcom directory. r=mccr8 2021-10-05 00:29:56 +00:00
LazyIdleThread.cpp
LazyIdleThread.h
LeakRefPtr.h
MainThreadIdlePeriod.cpp Bug 1733308 - Fix non-unified builds errors in xpcom/threads. r=xpcom-reviewers,mccr8 2021-10-01 01:49:18 +00:00
MainThreadIdlePeriod.h
MainThreadUtils.h Bug 1718262 - Remove duplicated declaration of NS_GetCurrentThread. r=mccr8 2021-06-25 18:35:09 +00:00
Monitor.h
MozPromise.h Bug 1629064 - pt 9. Use the current idle slice to start the GC if we can r=smaug 2021-05-12 06:46:11 +00:00
MozPromiseInlines.h Bug 1729458 - Part 1: Simplify DomPromiseListener, r=smaug,rpl 2021-09-14 15:02:58 +00:00
Mutex.h Bug 1727558 - Implement an RAII class for Mutex::TryLock. r=xpcom-reviewers,nika 2021-09-01 10:10:24 +00:00
PerformanceCounter.cpp
PerformanceCounter.h
Queue.h Bug 1733308 - Fix non-unified builds errors in xpcom/tests/gtest. r=xpcom-reviewers,mccr8 2021-10-01 01:49:19 +00:00
RWLock.cpp Bug 1727563 - Implement TryLock methods and RAII helpers for RWLock. r=xpcom-reviewers,nika 2021-09-08 10:40:07 +00:00
RWLock.h Bug 1727563 - Implement TryLock methods and RAII helpers for RWLock. r=xpcom-reviewers,nika 2021-09-08 10:40:07 +00:00
RecursiveMutex.cpp
RecursiveMutex.h
ReentrantMonitor.h
SchedulerGroup.cpp Bug 1718333 - Remove unnecessary AssertLinkThread assertions, r=handyman 2021-07-15 21:09:55 +00:00
SchedulerGroup.h Bug 1675820 - Part 6: Make DocGroup cycle-collected, r=farre,smaug 2021-03-18 19:24:50 +00:00
SharedThreadPool.cpp Bug 1731564: Use motivated SpinEventLoopUntil inside xpcom/*. r=xpcom-reviewers,nika 2021-10-07 08:06:16 +00:00
SharedThreadPool.h
SpinEventLoopUntil.h Bug 1731564: Add nested event loop stack to nsTerminator stderr output. r=xpcom-reviewers,nika 2021-10-07 08:06:17 +00:00
StateMirroring.h
StateWatching.h Backed out 2 changesets (bug 1738931) for causing mochitest failures on VideoConduit and WatchManager CLOSED TREE 2021-11-11 14:06:57 +02:00
SyncRunnable.h
SynchronizedEventQueue.cpp
SynchronizedEventQueue.h
TaskCategory.h
TaskController.cpp Bug 1738285 - move AUTO_PROFILE_FOLLOWING_RUNNABLE to its own header, r=gerald. 2021-10-28 20:35:06 +00:00
TaskController.h Bug 1727517 - Require task controller tasks to have a name, r=bas. 2021-08-31 13:41:45 +00:00
TaskDispatcher.h
TaskQueue.cpp Bug 1743895: Add names to all TaskQueues, remove no-name constructor r=nika,necko-reviewers 2021-12-03 03:16:15 +00:00
TaskQueue.h Bug 1743895: Add names to all TaskQueues, remove no-name constructor r=nika,necko-reviewers 2021-12-03 03:16:15 +00:00
ThreadBound.h
ThreadDelay.cpp
ThreadDelay.h
ThreadEventQueue.cpp Bug 1736751 - Use swap in ThreadEventQueue::SetObserver. r=KrisWright 2021-11-08 17:37:02 +00:00
ThreadEventQueue.h
ThreadEventTarget.cpp Bug 1731564: Use motivated SpinEventLoopUntil inside xpcom/*. r=xpcom-reviewers,nika 2021-10-07 08:06:16 +00:00
ThreadEventTarget.h Bug 1695580 - In xpcom, cancel pending DelayedRunnable timers on shutdown. r=KrisWright 2021-04-06 20:15:11 +00:00
ThreadLocalVariables.cpp
ThrottledEventQueue.cpp
ThrottledEventQueue.h
TimerThread.cpp Bug 1738627 - profiler_thread_is_being_profiled_for_markers - r=canaltinova 2021-11-08 23:59:35 +00:00
TimerThread.h Bug 1729964 - Move timer-release threading assert from TimerThread to nsTimerImpl. r=xpcom-reviewers,nika 2021-10-06 14:33:41 +00:00
VsyncTaskManager.cpp Bug 1708070 - Use VsyncTaskManager::WillRunTask to change InputVsyncState r=smaug 2021-04-29 16:39:30 +00:00
VsyncTaskManager.h Bug 1733308 - Fix non-unified builds errors in xpcom/threads. r=xpcom-reviewers,mccr8 2021-10-01 01:49:18 +00:00
components.conf
moz.build Bug 1733308 - Fix non-unified builds errors in xpcom/threads. r=xpcom-reviewers,mccr8 2021-10-01 01:49:18 +00:00
nsEnvironment.cpp
nsEnvironment.h
nsICancelableRunnable.h
nsIDelayedRunnableObserver.h Bug 1695580 - In xpcom, cancel pending DelayedRunnable timers on shutdown. r=KrisWright 2021-04-06 20:15:11 +00:00
nsIDirectTaskDispatcher.idl
nsIDiscardableRunnable.h
nsIEnvironment.idl
nsIEventTarget.idl
nsIIdlePeriod.idl
nsIIdleRunnable.h
nsINamed.idl
nsIProcess.idl
nsIRunnable.idl Bug 1734809 - add a new task priority between vsync and control, r=bas 2021-10-08 19:29:36 +00:00
nsISerialEventTarget.idl
nsISupportsPriority.idl
nsIThread.idl
nsIThreadInternal.idl
nsIThreadManager.idl Bug 1696397: Move SpinEventLoopUntilOrShutdown to -Quit and move the current shutdown state logic from nsThreadManager to AppShutdown; r=kmag,xpcom-reviewers 2021-03-17 08:07:48 +00:00
nsIThreadPool.idl
nsITimer.idl Bug 1529581 - Introduce initHighResolutionWithNamedFuncCallback for nsITimer. r=xpcom-reviewers,nika 2021-11-03 15:23:27 +00:00
nsMemoryPressure.cpp Bug 1733308 - Fix non-unified builds errors in xpcom/threads. r=xpcom-reviewers,mccr8 2021-10-01 01:49:18 +00:00
nsMemoryPressure.h Bug 1701368 - Part3: Remove the MemPressure_Ongoing request. r=gsvelto 2021-07-06 22:30:58 +00:00
nsProcess.h Bug 1734262 - Suppress thread leak reports for the monitor thread. r=decoder 2021-10-16 16:29:32 +00:00
nsProcessCommon.cpp Bug 1519636 - Reformat recent changes to the Google coding style. r=firefox-build-system-reviewers,mhentges,sylvestre 2021-11-16 08:07:29 +00:00
nsProxyRelease.cpp Bug 1727497 - Return Dispatch result from NS_ProxyRelease; r=dom-storage-reviewers,xpcom-reviewers,nika,janv 2021-09-14 13:17:55 +00:00
nsProxyRelease.h Bug 1735299 - Remove last use of unnammed NS_ReleaseOnMainThread r=extension-reviewers,rpl,nhnt11 2021-10-19 13:44:25 +00:00
nsThread.cpp Bug 1741377: Add a check to verify the successful dispatch of the nsThread shutdown ack event. r=xpcom-reviewers,nika 2021-11-17 19:25:28 +00:00
nsThread.h Bug 1735129: Add thread-safe name getter to nsThread. r=xpcom-reviewers,nika 2021-10-21 11:51:08 +00:00
nsThreadManager.cpp Bug 1741131: Be explicit about the process type in the XPCOMSpinEventLoopStack annotation. r=xpcom-reviewers,nika 2021-11-23 17:47:59 +00:00
nsThreadManager.h Bug 1731564: Introduce a motivated SpinEventLoopUntil for direct use from C++. r=xpcom-reviewers,nika,necko-reviewers 2021-10-07 08:06:10 +00:00
nsThreadPool.cpp Bug 1740899: Make nsThreadPool::Shutdown(WithTimeout) return an error on re-entrance. r=xpcom-reviewers,nika 2021-11-19 18:00:52 +00:00
nsThreadPool.h
nsThreadSyncDispatch.h
nsThreadUtils.cpp Bug 1739727 - Part 2: Improve rust async support in moz_task, r=emilio 2021-12-07 20:01:41 +00:00
nsThreadUtils.h Bug 1734811 - consider to use higher priority for the imglib tasks r=tnikkel 2021-10-08 19:29:37 +00:00
nsTimerImpl.cpp Bug 1739421: Use kungFuDeathGrip when firing a timer r=bwc 2021-11-08 23:00:30 +00:00
nsTimerImpl.h Bug 1529581 - Introduce initHighResolutionWithNamedFuncCallback for nsITimer. r=xpcom-reviewers,nika 2021-11-03 15:23:27 +00:00