build/authorify.js
function(task, suppressCallbacks) {
  // subtask is now done
  task.state = DONE;

  delete sTasks[task.id];
  if(sVL >= 1) {
    forge.log.verbose(cat, '[%s][%s] finish',
      task.id, task.name, task);
  }

  // only do queue processing for root tasks
  if(task.parent === null) {
    // report error if queue is missing
    if(!(task.type in sTaskQueues)) {
      forge.log.error(cat,
        '[%s][%s] task queue missing [%s]',
        task.id, task.name, task.type);
    } else if(sTaskQueues[task.type].length === 0) {
      // report error if queue is empty
      forge.log.error(cat,
        '[%s][%s] task queue empty [%s]',
        task.id, task.name, task.type);
    } else if(sTaskQueues[task.type][0] !== task) {
      // report error if this task isn't the first in the queue
      forge.log.error(cat,
        '[%s][%s] task not first in queue [%s]',
        task.id, task.name, task.type);
    } else {
      // remove ourselves from the queue
      sTaskQueues[task.type].shift();
      // clean up queue if it is empty
      if(sTaskQueues[task.type].length === 0) {
        if(sVL >= 1) {
          forge.log.verbose(cat, '[%s][%s] delete queue [%s]',
            task.id, task.name, task.type);
        }
        /* Note: Only a task can delete a queue of its own type. This
         is used as a way to synchronize tasks. If a queue for a certain
         task type exists, then a task of that type is running.
         */
        delete sTaskQueues[task.type];
      } else {
        // dequeue the next task and start it
        if(sVL >= 1) {
          forge.log.verbose(cat,
            '[%s][%s] queue start next [%s] remain:%s',
            task.id, task.name, task.type,
            sTaskQueues[task.type].length);
        }
        sTaskQueues[task.type][0].start();
      }
    }

    if(!suppressCallbacks) {
      // call final callback if one exists
      if(task.error && task.failureCallback) {
        task.failureCallback(task);
      } else if(!task.error && task.successCallback) {
        task.successCallback(task);
      }
    }
  }
}
function(task, suppressCallbacks) {
  // subtask is now done
  task.state = DONE;

  delete sTasks[task.id];
  if(sVL >= 1) {
    forge.log.verbose(cat, '[%s][%s] finish',
      task.id, task.name, task);
  }

  // only do queue processing for root tasks
  if(task.parent === null) {
    // report error if queue is missing
    if(!(task.type in sTaskQueues)) {
      forge.log.error(cat,
        '[%s][%s] task queue missing [%s]',
        task.id, task.name, task.type);
    } else if(sTaskQueues[task.type].length === 0) {
      // report error if queue is empty
      forge.log.error(cat,
        '[%s][%s] task queue empty [%s]',
        task.id, task.name, task.type);
    } else if(sTaskQueues[task.type][0] !== task) {
      // report error if this task isn't the first in the queue
      forge.log.error(cat,
        '[%s][%s] task not first in queue [%s]',
        task.id, task.name, task.type);
    } else {
      // remove ourselves from the queue
      sTaskQueues[task.type].shift();
      // clean up queue if it is empty
      if(sTaskQueues[task.type].length === 0) {
        if(sVL >= 1) {
          forge.log.verbose(cat, '[%s][%s] delete queue [%s]',
            task.id, task.name, task.type);
        }
        /* Note: Only a task can delete a queue of its own type. This
         is used as a way to synchronize tasks. If a queue for a certain
         task type exists, then a task of that type is running.
         */
        delete sTaskQueues[task.type];
      } else {
        // dequeue the next task and start it
        if(sVL >= 1) {
          forge.log.verbose(cat,
            '[%s][%s] queue start next [%s] remain:%s',
            task.id, task.name, task.type,
            sTaskQueues[task.type].length);
        }
        sTaskQueues[task.type][0].start();
      }
    }

    if(!suppressCallbacks) {
      // call final callback if one exists
      if(task.error && task.failureCallback) {
        task.failureCallback(task);
      } else if(!task.error && task.successCallback) {
        task.successCallback(task);
      }
    }
  }
}
function ( task , suppressCallbacks ) { // subtask is now done task . state = DONE ; delete sTasks [ task . id ] ; if ( sVL >= 1 ) { forge . log . verbose ( cat , '[%s][%s] finish' , task . id , task . name , task ) ; } // only do queue processing for root tasks if ( task . parent === null ) { // report error if queue is missing if ( ! ( task . type in sTaskQueues ) ) { forge . log . error ( cat , '[%s][%s] task queue missing [%s]' , task . id , task . name , task . type ) ; } else if ( sTaskQueues [ task . type ] . length === 0 ) { // report error if queue is empty forge . log . error ( cat , '[%s][%s] task queue empty [%s]' , task . id , task . name , task . type ) ; } else if ( sTaskQueues [ task . type ] [ 0 ] !== task ) { // report error if this task isn't the first in the queue forge . log . error ( cat , '[%s][%s] task not first in queue [%s]' , task . id , task . name , task . type ) ; } else { // remove ourselves from the queue sTaskQueues [ task . type ] . shift ( ) ; // clean up queue if it is empty if ( sTaskQueues [ task . type ] . length === 0 ) { if ( sVL >= 1 ) { forge . log . verbose ( cat , '[%s][%s] delete queue [%s]' , task . id , task . name , task . type ) ; } /* Note: Only a task can delete a queue of its own type. This
         is used as a way to synchronize tasks. If a queue for a certain
         task type exists, then a task of that type is running.
         */ delete sTaskQueues [ task . type ] ; } else { // dequeue the next task and start it if ( sVL >= 1 ) { forge . log . verbose ( cat , '[%s][%s] queue start next [%s] remain:%s' , task . id , task . name , task . type , sTaskQueues [ task . type ] . length ) ; } sTaskQueues [ task . type ] [ 0 ] . start ( ) ; } } if ( ! suppressCallbacks ) { // call final callback if one exists if ( task . error && task . failureCallback ) { task . failureCallback ( task ) ; } else if ( ! task . error && task . successCallback ) { task . successCallback ( task ) ; } } } }
Finishes a task and looks for the next task in the queue to start.

@param task the task to finish.
@param suppressCallbacks true to suppress callbacks.
Finishes a task and looks for the next task in the queue to start .