Consider adding a non-leaking (fallible) variant of `nsIEventTarget::Dispatch`
Categories
(Core :: XPCOM, enhancement)
Tracking
()
People
(Reporter: nika, Unassigned)
References
Details
Dispatches to event targets are currently quite inconsistent. Some event targets (like nsThread
) will leak if the dispatch fails, making them effectively infallible, while others (like TaskQueue
) will not leak the runnable if the dispatch fails, meaning that dispatched runnables may be released on the wrong thread.
We should consider adding a new variant of Dispatch
to nsIEventTarget
which is explicitly fallible, and doesn't take ownership from the caller over the runnable unless it successfully dispatches. This could be combined with migrating all existing Dispatch
calls to consistently leak on failure, making it possible for callers to make the correct decisions for their use cases.
Alternatively, if changing the existing Dispatch
method to be consistent is too difficult (e.g. because of there being code depending on the existing behaviour), it may also be possible to add two explicit variants with leaking and non-leaking, and slowly migrate away from the existing Dispatch
call, however due to the number of consumers of the existing API this feels somewhat unappealing.
Description
•