Bug 662178 - Ensure Utils.nextTick timers aren't GC'ed prematurely... by not using timers. r=rnewman
authorPhilipp von Weitershausen <philipp@weitershausen.de>
Wed, 08 Jun 2011 18:12:12 +0200
changeset 71091 607c796463f2
parent 71090 8eae98fbd3fe
child 71092 930e5704e47d
push id20491
push userpweitershausen@mozilla.com
push date2011-06-15 09:24 +0000
treeherdermozilla-central@0a409e965d39 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs662178
milestone7.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 662178 - Ensure Utils.nextTick timers aren't GC'ed prematurely... by not using timers. r=rnewman
services/sync/modules/util.js
--- a/services/sync/modules/util.js
+++ b/services/sync/modules/util.js
@@ -930,23 +930,27 @@ let Utils = {
       if (typeof callback == "function") {
         callback.call(that);        
       }
     });
   },
 
   /**
    * Execute a function on the next event loop tick.
+   * 
+   * @param callback
+   *        Function to invoke.
+   * @param thisObj [optional]
+   *        Object to bind the callback to.
    */
   nextTick: function nextTick(callback, thisObj) {
     if (thisObj) {
       callback = callback.bind(thisObj);
     }
-    let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
-    timer.initWithCallback(callback, 0, timer.TYPE_ONE_SHOT);
+    Services.tm.currentThread.dispatch(callback, Ci.nsIThread.DISPATCH_NORMAL);
   },
 
   /**
    * Return a timer that is scheduled to call the callback after waiting the
    * provided time or as soon as possible. The timer will be set as a property
    * of the provided object with the given timer name.
    */
   namedTimer: function delay(callback, wait, thisObj, name) {