/*
Execute the scheduled function or return the scheduled value for a stream iteration
188588
function executeScheduleItem(schedule, iteration, value) {
  if (schedule.length < iteration + 1) {
    throw Error("ZLIQ: schedule for iteration " + iteration + " not defined");
  }
  let item = schedule[iteration];
  if (typeof item === "function") {
    return item(value);
  } else {
    return item;
  }
}
2719
function onProcCall(method, path /* devid , propname*/, args) {
    switch (method) {
    case 'GET':
        return onProcCallGet(method, path /* devid , propname*/, args);
    /* case 'POST' :
        if(devid!='settings' || args == undefined)
            return {error:'The format is wrong for settings.'};
        if( args.schedule instanceof Array && logger.updateschedule(args.schedule) )
            return {success:true,message:'New schedule settings are successfully saved'};
        else
            return {error:'Error in saving scheduled logging'};*/
    }
    const msg = `The specified method ${method}`
          + ' is not implemented in admin plugin.';
    return {error: msg};
}
1028892
function schedule(actionName) {
      timeout.clear();
      var timeoutMS = timeout.timeoutMS(actionName);
      log.debug({ actionName: actionName, timeoutMS: timeoutMS }, 'schedule');
      var args = { actionName: actionName, isPaused: _isPauseTriggered(timeoutMS) };
      if (timeoutMS > 0) return setTimeout(function () {
        return execute(args);
      }, timeoutMS);
      execute(args);
    }
157031
public static void executeHelp(String[] args, PrintStream stream) throws Exception {
        String subCmd = (args.length > 0) ? args[0] : "";
        args = AdminToolUtils.copyArrayCutFirst(args);
        if(subCmd.equals("async-job")) {
            AdminCommandAsyncJob.executeHelp(args, stream);
        } else if(subCmd.equals("scheduled")) {
            AdminCommandScheduled.executeHelp(args, stream);
        } else if(subCmd.equals("cleanup")) {
            AdminCommandCleanup.executeHelp(args, stream);
        } else if(subCmd.equals("debug")) {
            AdminCommandDebug.executeHelp(args, stream);
        } else if(subCmd.equals("meta")) {
            AdminCommandMeta.executeHelp(args, stream);
        } else if(subCmd.equals("quota")) {
            AdminCommandQuota.executeHelp(args, stream);
        } else if(subCmd.equals("store")) {
            AdminCommandStore.executeHelp(args, stream);
        } else if(subCmd.equals("stream")) {
            AdminCommandStream.executeHelp(args, stream);
        } else {
            args = AdminToolUtils.copyArrayAddFirst(args, subCmd);
            AdminCommandOther.executeHelp(args, stream);
        }
    }
1048595
public ListenableFuture<Void> mayGoActiveOrInactive(final SnapshotSchedule schedule)
    {
        return m_es.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                makeActivePrivate(schedule);
                return null;
            }
        });
    }
918874
@Override
    public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
        try {
            if (this.enterpriseConcurrentScheduler) {
                return new EnterpriseConcurrentTriggerScheduler().schedule(decorateTask(task, true), trigger);
            } else {
                ErrorHandler errorHandlerLocal = this.errorHandler != null ? this.errorHandler : TaskUtils
                        .getDefaultErrorHandler(true);
                return new ReschedulingRunnable(task, trigger, this.scheduledExecutor, errorHandlerLocal).schedule();
            }
        } catch (RejectedExecutionException ex) {
            throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task,
                    ex);
        }
    }
1110665
public static ScheduledFuture<?> runWithScheduleAtFixedRate(
            long initialDelayMillis, long periodMillis, Runnable runnable) {
        return runWithScheduleAtFixedRate(initialDelayMillis, periodMillis,
                "runWithScheduleAtFixedRate", runnable);
    }
121570
def execute(*args, &task)
      if ensure_capacity?
        @scheduled_task_count += 1
        @queue << [args, task]
      else
        if @max_queue != 0 && @queue.length >= @max_queue
          handle_fallback(*args, &task)
        end
      end
      prune_pool
    end
1333330
private void scheduleRetry() {
        Context appContext = getApplicationContext();
        long nextRetry = System.currentTimeMillis() + RetryPolicy.incrementAndGetTime(appContext);
        scheduleWingsService(appContext, nextRetry);
    }
412913
@Override
    public ScheduledFuture<?> schedule(Runnable task, Date startTime) {
        ScheduledExecutorService executor = getScheduledExecutor();
        long initialDelay = startTime.getTime() - System.currentTimeMillis();
        try {
            return executor.schedule(errorHandlingTask(task, false), initialDelay, TimeUnit.MILLISECONDS);
        } catch (RejectedExecutionException ex) {
            throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
        }
    }
826202
@Override
    public ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, Date startTime, long delay) {
        ScheduledExecutorService executor = getScheduledExecutor();
        long initialDelay = startTime.getTime() - System.currentTimeMillis();
        try {
            return executor.scheduleWithFixedDelay(errorHandlingTask(task, true), initialDelay, delay,
                    TimeUnit.MILLISECONDS);
        } catch (RejectedExecutionException ex) {
            throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
        }
    }
232720
function charybdis (iterator) {
  iterator = iterator || K
  const stream = new Writable({objectMode: true})
  const deferred = Promise.defer()

  const stats = stream.stats = {
    objects: 0,
    operations: 0,
    pending: 0,
    start: Date.now(),
    inEnd: 0,
    end: 0,
  }

  var sources = refcount()
  stream.on('pipe', onPipe)
  function onPipe (src) {
    sources.push()
    src.on('end', function () {
      sources.pop()
    })
    src.once('error', cleanup)
  }
  sources.on('clear', function () {
    stats.inEnd = Date.now()
    stream.emit('inEnd')
    tryResolve()
  })

  stream._write = function(obj, encoding, cb) {
    stats.objects++
    var op = iterator(obj)
    if (!op || !op.then) {
      tick()
      return cb()
    }

    stats.pending++
    stats.operations++

    tick()

    op.then(function () {
      stats.pending--
      tryResolve()
    },
    cleanup)

    cb()
  }

  function tryResolve() {
    // in streams ended and no operations pending?
    if (stats.inEnd && !stats.pending) { cleanup() }
    else tick()
  }

  function tick() {
    stream.emit('tick', stats)
  }

  function cleanup(err) {
    stream.removeListener('pipe', onPipe)
    sources.removeAllListeners()

    if (err) {
      deferred.reject(err)
    }
    stats.end = Date.now()

    deferred.resolve(stats)
  }

  stream.then = deferred.promise.then.bind(deferred.promise)

  return stream
}
746938
function(ri, Receiver, recv_url, AjaxObject) {
    var that = this;
    that.ri = ri;
    that.Receiver = Receiver;
    that.recv_url = recv_url;
    that.AjaxObject = AjaxObject;
    that._scheduleRecv();
}
757284
function _schedule() {
    // do not _schedule when there are timeouts in progress
    // this can be the case with async timeouts in non-paced mode.
    // _schedule will be executed again when all async timeouts are finished.
    if (!paced && Object.keys(current).length > 0) {
      return;
    }

    var next = timeouts[0];

    // cancel timer when running
    if (timeoutId) {
      clearTimeout(timeoutId);
      timeoutId = null;
    }

    if (running && next) {
      // schedule next timeout
      var time = next.time;
      var delay = time - timer.now();
      var realDelay = paced ? delay / rate : 0;

      function onTimeout() {
        // when running in non-paced mode, update the hyperTime to
        // adjust the time of the current event
        if (!paced) {
          hyperTime = (time > hyperTime && isFinite(time)) ? time : hyperTime;
        }

        // grab all expired timeouts from the queue
        var expired = _getExpiredTimeouts(time);
        // note: expired.length can never be zero (on every change of the queue, we reschedule)

        // execute all expired timeouts
        if (paced) {
          // in paced mode, we fire all timeouts in parallel,
          // and don't await their completion (they can do async operations)
          expired.forEach(function (timeout) {
            _execTimeout(timeout);
          });

          // schedule the next round
          _schedule();
        }
        else {
          // in non-paced mode, we execute all expired timeouts serially,
          // and wait for their completion in order to guarantee deterministic
          // order of execution
          function next() {
            var timeout = expired.shift();
            if (timeout) {
              _execTimeout(timeout, next);
            }
            else {
              // schedule the next round
              _schedule();
            }
          }
          next();
        }
      }

      timeoutId = setTimeout(onTimeout, Math.round(realDelay));
      // Note: Math.round(realDelay) is to defeat a bug in node.js v0.10.30,
      //       see https://github.com/joyent/node/issues/8065
    }
  }
903029
public <R> Stream<R> map(Function<T, R> function) {
        return stream().map(function);
    }
270517
function matchSchedule (value, sequence) {
    for (var i = 0, c = sequence.length; i < c; i++) {
      if (sequence[i] >= value) {
        return sequence[i] === value;
      }
    }

    return sequence[0] === value;
  }
1076284
def schedule(self, function, args=(), kwargs={}):
        
        self._check_pool_state()

        future = Future()
        payload = TaskPayload(function, args, kwargs)
        task = Task(next(self._task_counter), future, None, payload)

        self._context.task_queue.put(task)

        return future