Bug 1145201: Document OffThreadPromiseRuntimeState fields in more detail. r=luke
authorJim Blandy <jimb@mozilla.com>
Wed, 30 Jan 2019 18:59:02 +0000
changeset 457343 8993106d37a62df5e66c61b0e7d56d7d818d23a5
parent 457342 a89ff647fa824059fa9dc4f536a0bc4e22f710ae
child 457344 e35136a50450fe4132566c4d982b24656036b576
push id35506
push useropoprus@mozilla.com
push dateWed, 06 Feb 2019 09:47:29 +0000
treeherdermozilla-central@2853480ed90d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1145201
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1145201: Document OffThreadPromiseRuntimeState fields in more detail. r=luke Differential Revision: https://phabricator.services.mozilla.com/D17543
js/src/builtin/Promise.h
--- a/js/src/builtin/Promise.h
+++ b/js/src/builtin/Promise.h
@@ -536,21 +536,33 @@ using DispatchableFifo = Fifo<JS::Dispat
 class OffThreadPromiseRuntimeState {
   friend class OffThreadPromiseTask;
 
   // These fields are initialized once before any off-thread usage and thus do
   // not require a lock.
   JS::DispatchToEventLoopCallback dispatchToEventLoopCallback_;
   void* dispatchToEventLoopClosure_;
 
-  // These fields are mutated by any thread and are guarded by mutex_.
+  // All following fields are mutated by any thread and are guarded by mutex_.
   Mutex mutex_;
+
+  // A set of all OffThreadPromiseTasks that have successfully called 'init'.
+  // OffThreadPromiseTask's destructor removes them from the set.
+  OffThreadPromiseTaskSet live_;
+
+  // The allCancelled_ condition is waited on and notified during engine shutdown,
+  // communicating when all off-thread tasks in live_ are safe to be destroyed
+  // from the (shutting down) main thread. This condition is met when
+  // live_.count() == numCanceled_ where "canceled" means "the
+  // DispatchToEventLoopCallback failed after this task finished execution".
   ConditionVariable allCanceled_;
-  OffThreadPromiseTaskSet live_;
   size_t numCanceled_;
+
+  // The queue of JS::Dispatchables used by the DispatchToEventLoopCallback that
+  // calling js::UseInternalJobQueues installs.
   DispatchableFifo internalDispatchQueue_;
   ConditionVariable internalDispatchQueueAppended_;
   bool internalDispatchQueueClosed_;
 
   static bool internalDispatchToEventLoop(void*, JS::Dispatchable*);
   bool usingInternalDispatchQueue() const;
 
   void operator=(const OffThreadPromiseRuntimeState&) = delete;