2012-08-10 13:17:18 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2012 The Netty Project
|
|
|
|
*
|
|
|
|
* The Netty Project licenses this file to you under the Apache License,
|
|
|
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at:
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
2013-03-05 21:41:19 +01:00
|
|
|
package io.netty.util.concurrent;
|
2012-08-10 13:17:18 +02:00
|
|
|
|
2013-04-09 07:15:49 +02:00
|
|
|
import java.util.Iterator;
|
2013-04-27 09:39:19 +02:00
|
|
|
import java.util.List;
|
2013-03-28 11:56:58 +01:00
|
|
|
import java.util.concurrent.Callable;
|
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
2012-08-10 13:17:18 +02:00
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
2012-08-28 02:10:17 +02:00
|
|
|
/**
|
2015-02-03 20:54:48 +01:00
|
|
|
* The {@link EventExecutorGroup} is responsible for providing the {@link EventExecutor}'s to use
|
|
|
|
* via its {@link #next()} method. Besides this, it is also responsible for handling their
|
|
|
|
* life-cycle and allows shutting them down in a global fashion.
|
2012-08-28 02:10:17 +02:00
|
|
|
*
|
|
|
|
*/
|
2013-04-09 07:15:49 +02:00
|
|
|
public interface EventExecutorGroup extends ScheduledExecutorService, Iterable<EventExecutor> {
|
2012-08-10 13:17:18 +02:00
|
|
|
|
2013-04-27 09:39:19 +02:00
|
|
|
/**
|
2014-03-24 04:32:55 +01:00
|
|
|
* Returns {@code true} if and only if all {@link EventExecutor}s managed by this {@link EventExecutorGroup}
|
2017-04-19 22:37:03 +02:00
|
|
|
* are being {@linkplain #shutdownGracefully() shut down gracefully} or was {@linkplain #isShutdown() shut down}.
|
2013-04-27 09:39:19 +02:00
|
|
|
*/
|
|
|
|
boolean isShuttingDown();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shortcut method for {@link #shutdownGracefully(long, long, TimeUnit)} with sensible default values.
|
2013-06-12 01:00:54 +02:00
|
|
|
*
|
|
|
|
* @return the {@link #terminationFuture()}
|
2013-04-27 09:39:19 +02:00
|
|
|
*/
|
2013-06-12 01:00:54 +02:00
|
|
|
Future<?> shutdownGracefully();
|
2013-04-27 09:39:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Signals this executor that the caller wants the executor to be shut down. Once this method is called,
|
|
|
|
* {@link #isShuttingDown()} starts to return {@code true}, and the executor prepares to shut itself down.
|
|
|
|
* Unlike {@link #shutdown()}, graceful shutdown ensures that no tasks are submitted for <i>'the quiet period'</i>
|
|
|
|
* (usually a couple seconds) before it shuts itself down. If a task is submitted during the quiet period,
|
|
|
|
* it is guaranteed to be accepted and the quiet period will start over.
|
|
|
|
*
|
|
|
|
* @param quietPeriod the quiet period as described in the documentation
|
|
|
|
* @param timeout the maximum amount of time to wait until the executor is {@linkplain #shutdown()}
|
|
|
|
* regardless if a task was submitted during the quiet period
|
|
|
|
* @param unit the unit of {@code quietPeriod} and {@code timeout}
|
2013-06-12 01:00:54 +02:00
|
|
|
*
|
|
|
|
* @return the {@link #terminationFuture()}
|
|
|
|
*/
|
|
|
|
Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit);
|
|
|
|
|
|
|
|
/**
|
2014-03-24 04:32:55 +01:00
|
|
|
* Returns the {@link Future} which is notified when all {@link EventExecutor}s managed by this
|
|
|
|
* {@link EventExecutorGroup} have been terminated.
|
2013-04-27 09:39:19 +02:00
|
|
|
*/
|
2013-06-12 01:00:54 +02:00
|
|
|
Future<?> terminationFuture();
|
2013-04-27 09:39:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated {@link #shutdownGracefully(long, long, TimeUnit)} or {@link #shutdownGracefully()} instead.
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Deprecated
|
|
|
|
void shutdown();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated {@link #shutdownGracefully(long, long, TimeUnit)} or {@link #shutdownGracefully()} instead.
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Deprecated
|
|
|
|
List<Runnable> shutdownNow();
|
|
|
|
|
2012-08-10 13:17:18 +02:00
|
|
|
/**
|
2014-03-24 04:32:55 +01:00
|
|
|
* Returns one of the {@link EventExecutor}s managed by this {@link EventExecutorGroup}.
|
2012-08-10 13:17:18 +02:00
|
|
|
*/
|
|
|
|
EventExecutor next();
|
|
|
|
|
2013-04-09 07:15:49 +02:00
|
|
|
@Override
|
|
|
|
Iterator<EventExecutor> iterator();
|
|
|
|
|
2013-03-28 11:56:58 +01:00
|
|
|
@Override
|
|
|
|
Future<?> submit(Runnable task);
|
2012-08-10 13:17:18 +02:00
|
|
|
|
2013-03-28 11:56:58 +01:00
|
|
|
@Override
|
|
|
|
<T> Future<T> submit(Runnable task, T result);
|
2012-08-10 13:17:18 +02:00
|
|
|
|
2013-03-28 11:56:58 +01:00
|
|
|
@Override
|
|
|
|
<T> Future<T> submit(Callable<T> task);
|
2012-08-10 13:17:18 +02:00
|
|
|
|
2013-03-28 11:56:58 +01:00
|
|
|
@Override
|
|
|
|
ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit);
|
|
|
|
|
|
|
|
@Override
|
|
|
|
<V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit);
|
|
|
|
|
|
|
|
@Override
|
|
|
|
ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit);
|
|
|
|
|
|
|
|
@Override
|
|
|
|
ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit);
|
2012-08-10 13:17:18 +02:00
|
|
|
}
|