src/index.js
function _tryIdleCall(idleQueue) {
    // ensure this does not run in parallel
    if (idleQueue._tryIR || idleQueue._iC.size === 0)
        return;
    idleQueue._tryIR = true;

    // w8 one tick
    setTimeout(() => {
        // check if queue empty
        if (!idleQueue.isIdle()) {
            idleQueue._tryIR = false;
            return;
        }

        /**
         * wait 1 tick here
         * because many functions do IO->CPU->IO
         * which means the queue is empty for a short time
         * but the ressource is not idle
         */
        setTimeout(() => {
            // check if queue still empty
            if (!idleQueue.isIdle()) {
                idleQueue._tryIR = false;
                return;
            }

            // ressource is idle
            _resolveOneIdleCall(idleQueue);
            idleQueue._tryIR = false;
        }, 0);
    }, 0);
}
function _tryIdleCall(idleQueue) {
    // ensure this does not run in parallel
    if (idleQueue._tryIR || idleQueue._iC.size === 0)
        return;
    idleQueue._tryIR = true;

    // w8 one tick
    setTimeout(() => {
        // check if queue empty
        if (!idleQueue.isIdle()) {
            idleQueue._tryIR = false;
            return;
        }

        /**
         * wait 1 tick here
         * because many functions do IO->CPU->IO
         * which means the queue is empty for a short time
         * but the ressource is not idle
         */
        setTimeout(() => {
            // check if queue still empty
            if (!idleQueue.isIdle()) {
                idleQueue._tryIR = false;
                return;
            }

            // ressource is idle
            _resolveOneIdleCall(idleQueue);
            idleQueue._tryIR = false;
        }, 0);
    }, 0);
}
function _tryIdleCall ( idleQueue ) { // ensure this does not run in parallel if ( idleQueue . _tryIR || idleQueue . _iC . size === 0 ) return ; idleQueue . _tryIR = true ; // w8 one tick setTimeout ( ( ) => { // check if queue empty if ( ! idleQueue . isIdle ( ) ) { idleQueue . _tryIR = false ; return ; } /**
         * wait 1 tick here
         * because many functions do IO->CPU->IO
         * which means the queue is empty for a short time
         * but the ressource is not idle
         */ setTimeout ( ( ) => { // check if queue still empty if ( ! idleQueue . isIdle ( ) ) { idleQueue . _tryIR = false ; return ; } // ressource is idle _resolveOneIdleCall ( idleQueue ) ; idleQueue . _tryIR = false ; } , 0 ) ; } , 0 ) ; }
resolves the last entry of this._iC
but only if the queue is empty
@return {Promise}
resolves the last entry of this . _iC but only if the queue is empty