From 4e734f2a51cd4a762da0b852cf6dc15ba2287d57 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Tue, 12 May 2020 10:45:20 +0000 Subject: [PATCH] Bug 1592488 - P12. Run MozPromise's IPDL callbacks via direct tasks when the promise is resolved. r=nika Fix intermittent issues due to races. We now run the MozPromise generated by the IPDL bindings to run their callbacks via a direct task dispatch. This avoids a full trip to the back of the event queue for each additional asynchronous step when using MozPromise. A consequence to this change is that each IPDL actor's thread must have an AbstractThread allocated if IPDL MozPromises are used. It prevents unexpected racy behaviours when combining MozPromise with the other Resolve/Reject IPDL async declaration which was have lead to processing the events out of order. Differential Revision: https://phabricator.services.mozilla.com/D71593 --- ipc/ipdl/ipdl/lower.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index 4096ab91dee3..ccfb02df8c6f 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -4873,6 +4873,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): stmt = StmtCode( ''' RefPtr<${promise}> promise__ = new ${promise}(__func__); + promise__->UseDirectTaskDispatch(__func__); ${send}($,{args}); return promise__; ''',