/*
(non-Javadoc)

@see
org.jdiameter.common.api.app.Rf.IServerRfActionContext#srssionTimerCanceled
(org.jdiameter.api.Rf.ServerRfSession,
java.util.concurrent.ScheduledFuture)
334267
@Override
  @SuppressWarnings("unchecked")
  public void sessionTimerCanceled(ServerRfSession appSession, ScheduledFuture timer) throws InternalException {
    logger.info("sessionTimerCanceled :: appSession[" + appSession + "]");
  }
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);
        }
    }
393014
protected static void scheduleNextRetry(ClientRequestContext ctx,
                                            Consumer<? super Throwable> actionOnException,
                                            Runnable retryTask, long nextDelayMillis) {
        try {
            if (nextDelayMillis == 0) {
                ctx.contextAwareEventLoop().execute(retryTask);
            } else {
                @SuppressWarnings("unchecked")
                final ScheduledFuture<Void> scheduledFuture = (ScheduledFuture<Void>) ctx
                        .contextAwareEventLoop().schedule(retryTask, nextDelayMillis, TimeUnit.MILLISECONDS);
                scheduledFuture.addListener(future -> {
                    if (future.isCancelled()) {
                        // future is cancelled when the client factory is closed.
                        actionOnException.accept(new IllegalStateException(
                                ClientFactory.class.getSimpleName() + " has been closed."));
                    }
                });
            }
        } catch (Throwable t) {
            actionOnException.accept(t);
        }
    }
1261330
public static ScheduledFuture<?> runWithScheduleAtFixedRateOnStartTime(
            ZonedDateTime startDateTime, long periodMillis, Runnable runnable) {
        return runWithScheduleAtFixedRate(calInitialDelayMillis(startDateTime),
                periodMillis, "runWithScheduleAtFixedRateOnStartTime",
                runnable);
    }
1238387
protected void scheduleRunAsync(Runnable runnable, long delay, TimeUnit unit) {
		componentMainThreadExecutor.schedule(runnable, delay, unit);
	}
1051410
public void setScheduledActions(java.util.Collection<ScheduledAction> scheduledActions) {
        if (scheduledActions == null) {
            this.scheduledActions = null;
            return;
        }

        this.scheduledActions = new java.util.ArrayList<ScheduledAction>(scheduledActions);
    }
344214
public ScheduledFuture<?> schedule(Runnable command, TemporalAccessor time)
    {
        ensureWaiterRunning();
        log(logLevel, "schedule(%s, %s)", command, time);
        RunnableScheduledFutureImpl future = new RunnableScheduledFutureImpl(command, Instant.from(time), null, false);
        delayQueue.add(future);
        return future;
    }
535782
@SuppressWarnings("PMD")
  static <T> void schedule(
      ScheduledExecutorService executor, WeakReference<T> ref, long delay, Consumer<T> poll) {
    final AtomicReference<Future<?>> futureRef = new AtomicReference<>();
    final Runnable cancel = () -> {
      Future<?> f = futureRef.get();
      if (f != null) {
        f.cancel(false);
      }
    };
    final Runnable task = () -> {
      try {
        T r = ref.get();
        if (r != null) {
          poll.accept(r);
        } else {
          cancel.run();
        }
      } catch (Throwable t) {
        cancel.run();
      }
    };
    futureRef.set(executor.scheduleWithFixedDelay(task, delay, delay, TimeUnit.MILLISECONDS));
  }
529372
private void scheduleCreateRemoteListener() {

        final String methodName = "scheduleCreateRemoteListener";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName);
        }

        _timer.schedule(new TimerTask() {

            public void run() {

                createRemoteListenerDeactivateOnException(false);

                synchronized(SibRaStaticDestinationEndpointActivation.this) {

                    if (_remoteConnection != null) {

                        /*
                         * Successfully created a connection
                         */

                        SibTr.info(TRACE, "CONNECTED_CWSIV0777", new Object[] {
                                _remoteConnection.getConnection().getMeName(),
                                _endpointConfiguration.getDestination()
                                        .getDestinationName(),
                                _endpointConfiguration.getBusName(),
                                SibRaStaticDestinationEndpointActivation.this });

                    }

                }

            }
        }, RETRY_INTERVAL);

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }

    }
165606
@Override
    public void process(HttpServerResponse vertxResponse, ContainerResponse jerseyResponse) {
        Object obj = jerseyResponse.getRequestContext().getProperty(RequestProcessor.LAST_BYTE_TIMER_CONTEXT);
        if (obj instanceof Timer.Context) {
            Timer.Context context = (Timer.Context) obj;
            context.stop();
        }
    }
65523
public static ScheduledFuture<?> asyncExecutePeriodically(Runnable task, long delay, long interval, TimeUnit t) {
		if (task != null) {
			try {
				return Para.getScheduledExecutorService().scheduleAtFixedRate(task, delay, interval, t);
			} catch (RejectedExecutionException ex) {
				logger.warn(ex.getMessage());
			}
		}
		return null;
	}
1301644
@Override
    public ScheduledFuture<?> scheduleAtFixedRate(Runnable task, Date startTime, long period) {
        long initialDelay = startTime.getTime() - System.currentTimeMillis();
        try {
            return this.scheduledExecutor.scheduleAtFixedRate(decorateTask(task, true), initialDelay, period,
                    TimeUnit.MILLISECONDS);
        } catch (RejectedExecutionException ex) {
            throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task,
                    ex);
        }
    }
1144297
public synchronized void schedule()
    {
        // Avoid scheduling a timer that was destroyed on another thread and
        // avoid scheduling a timer twice, which might be attempted if two
        // threads concurrently attempt to cancel and then both rollback.
        if (ivTaskHandler == null && !ivDestroyed)
        {
            // Create the timer task handler (Runnable/Listener) and schedule the task
            ivTaskHandler = ivContainer.getEJBRuntime().createNonPersistentTimerTaskHandler(this);

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "schedule: scheduling timer for " + ivExpiration + " / " + new Date(ivExpiration));

            ivTaskHandler.schedule(ivExpiration);
        }
        else
        {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "schedule: timer already scheduled or destroyed : destroyed=" + ivDestroyed);
        }
    }
850184
private void scheduleSendTask(boolean runNow) {
        TimerTask task = new TimerTask() {
            @Override
            public void run() {

                byte[] packet;

                try {
                    packet = packets.get(0);

                } catch (IndexOutOfBoundsException e) {
                    // No packets left; return without scheduling another run
                    return;

                }

                charc.setValue(packet);
                boolean result = gattClient.writeCharacteristic(charc);

                if (result) {
                    packets.remove(0);
                    int id = ids.remove(0);
                    retries = 0;

                    if (onPacketSent != null) {
                        onPacketSent.onResult(id);
                    }
                    Log.d(TAG, "Packet " + id + " sent after " + retries + " retries");

                } else {
                    retries++;

                }

                scheduleSendTask(false);
            }
        };

        if (runNow) {
            task.run();

        } else {
            sendTimer.schedule(task, SEND_INTERVAL);

        }
    }
536897
@Override
    public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) throws NotConnectedException, InterruptedException {
        RTPBridge rtpBridge = RTPBridge.relaySession(lc.getConnection(), lc.getSessionId(), lc.getPassword(), rc, lc);
    }
208710
protected void setScheduler(CFMLEngine engine, Resource scheduleDirectory) throws PageException {
	if (scheduleDirectory == null) {
	    if (this.scheduler == null) this.scheduler = new SchedulerImpl(engine, "<?xml version=\"1.0\"?>\n<schedule></schedule>", this);
	    return;
	}

	if (!isDirectory(scheduleDirectory)) throw new ExpressionException("schedule task directory " + scheduleDirectory + " doesn't exist or is not a directory");
	try {
	    if (this.scheduler == null) this.scheduler = new SchedulerImpl(engine, this, scheduleDirectory, SystemUtil.getCharset().name());
	}
	catch (Exception e) {
	    throw Caster.toPageException(e);
	}
    }
1105768
public void setScheduleDefinitions(java.util.Collection<String> scheduleDefinitions) {
        if (scheduleDefinitions == null) {
            this.scheduleDefinitions = null;
            return;
        }

        this.scheduleDefinitions = new com.amazonaws.internal.SdkInternalList<String>(scheduleDefinitions);
    }