本文整理了Java中io.netty.channel.EventLoop.scheduleAtFixedRate()
方法的一些代码示例,展示了EventLoop.scheduleAtFixedRate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EventLoop.scheduleAtFixedRate()
方法的具体详情如下:
包路径:io.netty.channel.EventLoop
类名称:EventLoop
方法名:scheduleAtFixedRate
暂无
代码示例来源:origin: normanmaurer/netty-in-action
/**
* Listing 7.4 Scheduling a recurring task with EventLoop
* */
public static void scheduleFixedViaEventLoop() {
Channel ch = CHANNEL_FROM_SOMEWHERE; // get reference from somewhere
ScheduledFuture<?> future = ch.eventLoop().scheduleAtFixedRate(
new Runnable() {
@Override
public void run() {
System.out.println("Run every 60 seconds");
}
}, 60, 60, TimeUnit.SECONDS);
}
代码示例来源:origin: normanmaurer/netty-in-action
/**
* Listing 7.5 Canceling a task using ScheduledFuture
* */
public static void cancelingTaskUsingScheduledFuture(){
Channel ch = CHANNEL_FROM_SOMEWHERE; // get reference from somewhere
ScheduledFuture<?> future = ch.eventLoop().scheduleAtFixedRate(
new Runnable() {
@Override
public void run() {
System.out.println("Run every 60 seconds");
}
}, 60, 60, TimeUnit.SECONDS);
// Some other code that runs...
boolean mayInterruptIfRunning = false;
future.cancel(mayInterruptIfRunning);
}
}
代码示例来源:origin: ReactiveX/RxNetty
@Override
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay,
long period,
TimeUnit unit) {
return next().scheduleAtFixedRate(command, initialDelay, period, unit);
}
代码示例来源:origin: eclipse-vertx/vert.x
InternalTimerHandler(long timerID, Handler<Long> runnable, boolean periodic, long delay, ContextImpl context) {
this.context = context;
this.timerID = timerID;
this.handler = runnable;
this.periodic = periodic;
this.cancelled = new AtomicBoolean();
EventLoop el = context.nettyEventLoop();
Runnable toRun = () -> context.runOnContext(this);
if (periodic) {
future = el.scheduleAtFixedRate(toRun, delay, delay, TimeUnit.MILLISECONDS);
} else {
future = el.schedule(toRun, delay, TimeUnit.MILLISECONDS);
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public Future<?> shutdownGracefully(final long l, final long l2, final TimeUnit timeUnit) {
if (channelFactoryCount.decrementAndGet() == 0) {
shutdown.compareAndSet(null, next().scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
synchronized (SharedEventLoopGroup.class) {
if (shutdown.get() != null) {
Future<?> future = SharedEventLoopGroup.super.shutdownGracefully(l, l2, timeUnit);
future.addListener(new FutureListener<Object>() {
@Override
public void operationComplete(Future<Object> future) throws Exception {
if (future.isSuccess()) {
terminationPromise.setSuccess(null);
} else {
terminationPromise.setFailure(future.cause());
}
}
});
instance = null;
}
}
}
}, 10, 10, TimeUnit.SECONDS));
}
return terminationPromise;
}
}
代码示例来源:origin: line/armeria
@Override
public ScheduledFuture<?> scheduleAtFixedRate(
Runnable command, long initialDelay, long period, TimeUnit unit) {
return delegate().scheduleAtFixedRate(context().makeContextAware(command), initialDelay, period, unit);
}
代码示例来源:origin: io.vertx/vertx-core
InternalTimerHandler(long timerID, Handler<Long> runnable, boolean periodic, long delay, ContextImpl context) {
this.context = context;
this.timerID = timerID;
this.handler = runnable;
this.periodic = periodic;
this.cancelled = new AtomicBoolean();
EventLoop el = context.nettyEventLoop();
Runnable toRun = () -> context.runOnContext(this);
if (periodic) {
future = el.scheduleAtFixedRate(toRun, delay, delay, TimeUnit.MILLISECONDS);
} else {
future = el.schedule(toRun, delay, TimeUnit.MILLISECONDS);
}
if (metrics != null) {
metrics.timerCreated(timerID);
}
}
代码示例来源:origin: reactor/reactor-netty
@Override
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
long initialDelay,
long period,
TimeUnit unit) {
return next().scheduleAtFixedRate(command, initialDelay, period, unit);
}
代码示例来源:origin: io.projectreactor.ipc/reactor-netty
@Override
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
long initialDelay,
long period,
TimeUnit unit) {
return next().scheduleAtFixedRate(command, initialDelay, period, unit);
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
@Override
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
long initialDelay,
long period,
TimeUnit unit) {
return next().scheduleAtFixedRate(command, initialDelay, period, unit);
}
代码示例来源:origin: io.projectreactor/reactor-netty
@Override
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
long initialDelay,
long period,
TimeUnit unit) {
return next().scheduleAtFixedRate(command, initialDelay, period, unit);
}
代码示例来源:origin: apache/activemq-artemis
@Override
public Future<?> shutdownGracefully(final long l, final long l2, final TimeUnit timeUnit) {
if (channelFactoryCount.decrementAndGet() == 0) {
shutdown.compareAndSet(null, next().scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
synchronized (SharedEventLoopGroup.class) {
if (shutdown.get() != null) {
Future<?> future = SharedEventLoopGroup.super.shutdownGracefully(l, l2, timeUnit);
future.addListener(new FutureListener<Object>() {
@Override
public void operationComplete(Future<Object> future) throws Exception {
if (future.isSuccess()) {
terminationPromise.setSuccess(null);
} else {
terminationPromise.setFailure(future.cause());
}
}
});
instance = null;
}
}
}
}, 10, 10, TimeUnit.SECONDS));
}
return terminationPromise;
}
}
代码示例来源:origin: org.apache.activemq/artemis-core-client
@Override
public Future<?> shutdownGracefully(final long l, final long l2, final TimeUnit timeUnit) {
if (channelFactoryCount.decrementAndGet() == 0) {
shutdown.compareAndSet(null, next().scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
synchronized (SharedEventLoopGroup.class) {
if (shutdown.get() != null) {
Future<?> future = SharedEventLoopGroup.super.shutdownGracefully(l, l2, timeUnit);
future.addListener(new FutureListener<Object>() {
@Override
public void operationComplete(Future<Object> future) throws Exception {
if (future.isSuccess()) {
terminationPromise.setSuccess(null);
} else {
terminationPromise.setFailure(future.cause());
}
}
});
instance = null;
}
}
}
}, 10, 10, TimeUnit.SECONDS));
}
return terminationPromise;
}
}
代码示例来源:origin: apache/activemq-artemis
@Override
public Future<?> shutdownGracefully(final long l, final long l2, final TimeUnit timeUnit) {
if (channelFactoryCount.decrementAndGet() == 0) {
shutdown.compareAndSet(null, next().scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
synchronized (SharedEventLoopGroup.class) {
if (shutdown.get() != null) {
Future<?> future = SharedEventLoopGroup.super.shutdownGracefully(l, l2, timeUnit);
future.addListener(new FutureListener<Object>() {
@Override
public void operationComplete(Future<Object> future) throws Exception {
if (future.isSuccess()) {
terminationPromise.setSuccess(null);
} else {
terminationPromise.setFailure(future.cause());
}
}
});
instance = null;
}
}
}
}, 10, 10, TimeUnit.SECONDS));
}
return terminationPromise;
}
}
代码示例来源:origin: org.apache.activemq/artemis-jms-client-all
@Override
public Future<?> shutdownGracefully(final long l, final long l2, final TimeUnit timeUnit) {
if (channelFactoryCount.decrementAndGet() == 0) {
shutdown.compareAndSet(null, next().scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
synchronized (SharedEventLoopGroup.class) {
if (shutdown.get() != null) {
Future<?> future = SharedEventLoopGroup.super.shutdownGracefully(l, l2, timeUnit);
future.addListener(new FutureListener<Object>() {
@Override
public void operationComplete(Future<Object> future) throws Exception {
if (future.isSuccess()) {
terminationPromise.setSuccess(null);
} else {
terminationPromise.setFailure(future.cause());
}
}
});
instance = null;
}
}
}
}, 10, 10, TimeUnit.SECONDS));
}
return terminationPromise;
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
@Override
public Future<?> shutdownGracefully(final long l, final long l2, final TimeUnit timeUnit) {
if (channelFactoryCount.decrementAndGet() == 0) {
shutdown.compareAndSet(null, next().scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
synchronized (SharedEventLoopGroup.class) {
if (shutdown.get() != null) {
Future<?> future = SharedEventLoopGroup.super.shutdownGracefully(l, l2, timeUnit);
future.addListener(new FutureListener<Object>() {
@Override
public void operationComplete(Future<Object> future) throws Exception {
if (future.isSuccess()) {
terminationPromise.setSuccess(null);
} else {
terminationPromise.setFailure(future.cause());
}
}
});
instance = null;
}
}
}
}, 10, 10, TimeUnit.SECONDS));
}
return terminationPromise;
}
}
代码示例来源:origin: org.hornetq/hornetq-core-client
shutdown.compareAndSet(null, next().scheduleAtFixedRate(new Runnable()
代码示例来源:origin: aadnk/ProtocolLib
@Override
public ScheduledFuture<?> scheduleAtFixedRate(Runnable action, long arg1, long arg2, TimeUnit arg3) {
return getDelegate().scheduleAtFixedRate(schedulingRunnable(action), arg1, arg2, arg3);
}
代码示例来源:origin: com.github.cloudfoundry-community/nats-client
@Override
public Registration publish(String subject, String body, String replyTo, long period, TimeUnit unit) {
final ClientPublishFrame publishFrame = new ClientPublishFrame(subject, body, replyTo);
final ScheduledFuture<?> scheduledFuture = eventLoopGroup.next().scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
if (isConnected()) {
publish(publishFrame);
}
}
}, 0l, period, unit);
return new Registration() {
@Override
public void remove() {
scheduledFuture.cancel(false);
}
};
}
代码示例来源:origin: cloudfoundry-community/java-nats
@Override
public Registration publish(String subject, String body, String replyTo, long period, TimeUnit unit) {
final ClientPublishFrame publishFrame = new ClientPublishFrame(subject, body, replyTo);
final ScheduledFuture<?> scheduledFuture = eventLoopGroup.next().scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
if (isConnected()) {
publish(publishFrame);
}
}
}, 0l, period, unit);
return new Registration() {
@Override
public void remove() {
scheduledFuture.cancel(false);
}
};
}
内容来源于网络,如有侵权,请联系作者删除!