B2G/gecko/services/common/async.js
/**
   * Wait for a sync callback to finish.
   */
Wait for a sync callback to finish.
Wait for a sync callback to finish .
function waitForSyncCallback(callback) {
    let thread = Cc["@mozilla.org/thread-manager;1"].getService().currentThread;
    while (Async.checkAppReady() && callback.state == CB_READY) {
      thread.processNextEvent(true);
    }
    let state = callback.state;
    callback.state = CB_READY;
    if (state == CB_FAIL) {
      throw callback.value;
    }
    return callback.value;
  }
function waitForSyncCallback ( callback ) { let thread = Cc [ "@mozilla.org/thread-manager;1" ] . getService ( ) . currentThread ; while ( Async . checkAppReady ( ) && callback . state == CB_READY ) { thread . processNextEvent ( true ) ; } let state = callback . state ; callback . state = CB_READY ; if ( state == CB_FAIL ) { throw callback . value ; } return callback . value ; }
Wait for a sync callback to finish.
Wait for a sync callback to finish .
// Grab the current thread so we can make it give up priority. // Keep waiting until our callback is triggered (unless the app is quitting). // Reset the state of the callback to prepare for another call. // Throw the value the callback decided to fail with. // Return the value passed to the callback.