Examples of ScheduledFuture


Examples of edu.emory.mathcs.backport.java.util.concurrent.ScheduledFuture

        clockDaemon.allowCoreThreadTimeOut(false);
    }
    static HashMap clockTickets = new HashMap();

    synchronized static public void executePeriodically(final Runnable task, long period) {
        ScheduledFuture ticket = clockDaemon.scheduleAtFixedRate(task, period, period, TimeUnit.MILLISECONDS);
        clockTickets.put(task, ticket);
    }
View Full Code Here

Examples of edu.emory.mathcs.backport.java.util.concurrent.ScheduledFuture

        ScheduledFuture ticket = clockDaemon.scheduleAtFixedRate(task, period, period, TimeUnit.MILLISECONDS);
        clockTickets.put(task, ticket);
    }

    synchronized static public void cancel(Runnable task) {
        ScheduledFuture ticket = (ScheduledFuture) clockTickets.remove(task);
        if( ticket!=null ) {
            ticket.cancel(false);
            if (ticket instanceof Runnable)
              clockDaemon.remove((Runnable) ticket);           
        }
    }
View Full Code Here

Examples of io.fletty.util.concurrent.ScheduledFuture

        }
        return b1;
    }

    public ScheduledFuture setTimeout(int time, final Runnable runnable) {
        ScheduledFuture schedule = null;
        try {
            lock.readLock().lock();
            if (loopGroup != null) {
                schedule = loopGroup.schedule(runnable, time, TimeUnit.MILLISECONDS);
            }
View Full Code Here

Examples of io.netty.util.concurrent.ScheduledFuture

    @SuppressWarnings( { "rawtypes", "unchecked" })
    private ChannelHandlerContext channelHandlerContext() {
        final ChannelHandlerContext ctx = mock(ChannelHandlerContext.class);
        final EventExecutor eventExecutor = mock(EventExecutor.class);
        final ScheduledFuture future = mock(ScheduledFuture.class);
        when(eventExecutor.scheduleAtFixedRate(any(Runnable.class), anyLong(), anyLong(), any(TimeUnit.class))).thenReturn(future);
        when(ctx.executor()).thenReturn(eventExecutor);
        when(ctx.pipeline()).thenReturn(mock(ChannelPipeline.class));
        return ctx;
    }
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

     * Schedules the task for execution with the contained timeout. If a task
     * is already pending or running, it will be cancelled (not interrupted).
     * The new task will be scheduled to run in now + timeout.
     */
    public ScheduledFuture schedule() {
        ScheduledFuture currentTask = cancelCurrentTask();
        ScheduledFuture newTask = m_executor.schedule(m_task, m_timeout, m_timeUnit);
        m_futureRef.compareAndSet(currentTask, newTask);
        return newTask;
    }
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

    /**
     * @return the current task, or <code>null</code> if no task is available.
     */
    private ScheduledFuture cancelCurrentTask() {
        ScheduledFuture currentTask = (ScheduledFuture) m_futureRef.get();
        if (currentTask != null) {
            // Doesn't matter for completed tasks...
            currentTask.cancel(false /* mayInterruptIfRunning */);
        }
        return currentTask;
    }
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

     */
    private void scheduleCancelInflight(final String queueUrl, final Message message) {
        if (scheduler != null) {
            int visibility = getVisibilityForQueue(queueUrl);
            if (visibility > 0) {
                ScheduledFuture task = scheduler.schedule(new Runnable() {
                    @Override
                    public void run() {
                        synchronized (messages) {
                            // put it back!
                            messages.add(message);
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

    @Override
    public void deleteMessage(DeleteMessageRequest deleteMessageRequest) throws AmazonClientException {
        String receiptHandle = deleteMessageRequest.getReceiptHandle();
        if (inFlight.containsKey(receiptHandle)) {
            ScheduledFuture inFlightTask = inFlight.get(receiptHandle);
            inFlightTask.cancel(true);
        }
    }
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

      Configuration cfg = getCfg().expiration().wakeUpInterval(789L).build();

      ScheduledExecutorService mockService = mock(ScheduledExecutorService.class);
      em.initialize(mockService, "", cfg, null, null, null);

      ScheduledFuture mockFuture = mock(ScheduledFuture.class);
      when(mockService.scheduleWithFixedDelay(isA(EvictionManagerImpl.ScheduledTask.class), eq(789l),
                                                eq(789l), eq(TimeUnit.MILLISECONDS)))
            .thenReturn(mockFuture);
      em.start();
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

            JDKCallableJob callableJob = new JDKCallableJob( job,
                                                             ctx,
                                                             trigger,
                                                             jobHandle,
                                                             this.scheduler );
            ScheduledFuture future = schedule( date,
                                               callableJob,
                                               this.scheduler );
            jobHandle.setFuture( future );

            return jobHandle;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.