本文整理了Java中io.netty.channel.EventLoop.submit()
方法的一些代码示例,展示了EventLoop.submit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EventLoop.submit()
方法的具体详情如下:
包路径:io.netty.channel.EventLoop
类名称:EventLoop
方法名:submit
暂无
代码示例来源:origin: redisson/redisson
private void scheduleFlush(final ChannelHandlerContext ctx) {
if (nextScheduledFlush == null) {
// Run as soon as possible, but still yield to give a chance for additional writes to enqueue.
nextScheduledFlush = ctx.channel().eventLoop().submit(flushTask);
}
}
代码示例来源:origin: wildfly/wildfly
private void scheduleFlush(final ChannelHandlerContext ctx) {
if (nextScheduledFlush == null) {
// Run as soon as possible, but still yield to give a chance for additional writes to enqueue.
nextScheduledFlush = ctx.channel().eventLoop().submit(flushTask);
}
}
代码示例来源:origin: ReactiveX/RxNetty
@Override
public Future<?> submit(Runnable task) {
return next().submit(task);
}
代码示例来源:origin: ReactiveX/RxNetty
@Override
public <T> Future<T> submit(Callable<T> task) {
return next().submit(task);
}
代码示例来源:origin: ReactiveX/RxNetty
@Override
public <T> Future<T> submit(Runnable task, T result) {
return next().submit(task, result);
}
代码示例来源:origin: ReactiveX/RxNetty
@Override
public void call(Subscriber<? super Void> subscriber) {
if (null == c) {
subscriber.onCompleted();
} else {
/**
* Executing the release on the eventloop to avoid race-conditions between code cleaning up
* connection in the pipeline and the connecting being released to the pool.
*/
c.unsafeNettyChannel()
.eventLoop()
.submit(new ReleaseTask(c, subscriber));
}
}
});
代码示例来源:origin: line/armeria
@Override
public void cancel(@Nullable String message, @Nullable Throwable cause) {
if (ctx.eventLoop().inEventLoop()) {
doCancel(message, cause);
} else {
ctx.eventLoop().submit(() -> doCancel(message, cause));
}
}
代码示例来源:origin: line/armeria
@Override
public void halfClose() {
if (ctx.eventLoop().inEventLoop()) {
req.close();
} else {
ctx.eventLoop().submit((Runnable) req::close);
}
}
代码示例来源:origin: line/armeria
@Override
public void close(Status status, Metadata unusedGrpcMetadata) {
if (ctx.eventLoop().inEventLoop()) {
doClose(status, unusedGrpcMetadata);
} else {
ctx.eventLoop().submit(() -> doClose(status, unusedGrpcMetadata));
}
}
代码示例来源:origin: line/armeria
@Override
public void request(int numMessages) {
if (ctx.eventLoop().inEventLoop()) {
responseReader.request(numMessages);
} else {
ctx.eventLoop().submit(() -> responseReader.request(numMessages));
}
}
代码示例来源:origin: ReactiveX/RxNetty
public Future<Void> runFromChannelEventLoop(Callable<Void> runnable) throws Exception {
Future<Void> toReturn = channel.eventLoop().submit(runnable);
runAllPendingTasksOnChannel();
return toReturn;
}
代码示例来源:origin: line/armeria
@Override
public void request(int numMessages) {
if (ctx.eventLoop().inEventLoop()) {
messageReader.request(numMessages);
} else {
ctx.eventLoop().submit(() -> messageReader.request(numMessages));
}
}
代码示例来源:origin: line/armeria
@Override
public void sendHeaders(Metadata unusedGrpcMetadata) {
if (ctx.eventLoop().inEventLoop()) {
doSendHeaders(unusedGrpcMetadata);
} else {
ctx.eventLoop().submit(() -> doSendHeaders(unusedGrpcMetadata));
}
}
代码示例来源:origin: netty/netty
private void runFinishPeerReadTask(final LocalChannel peer) {
// If the peer is writing, we must wait until after reads are completed for that peer before we can read. So
// we keep track of the task, and coordinate later that our read can't happen until the peer is done.
final Runnable finishPeerReadTask = new Runnable() {
@Override
public void run() {
finishPeerRead0(peer);
}
};
try {
if (peer.writeInProgress) {
peer.finishReadFuture = peer.eventLoop().submit(finishPeerReadTask);
} else {
peer.eventLoop().execute(finishPeerReadTask);
}
} catch (Throwable cause) {
logger.warn("Closing Local channels {}-{} because exception occurred!", this, peer, cause);
close();
peer.close();
PlatformDependent.throwException(cause);
}
}
代码示例来源:origin: line/armeria
@Override
public void sendMessage(O message) {
pendingMessagesUpdater.incrementAndGet(this);
if (ctx.eventLoop().inEventLoop()) {
doSendMessage(message);
} else {
ctx.eventLoop().submit(() -> doSendMessage(message));
}
}
代码示例来源:origin: line/armeria
@Override
public void sendMessage(I message) {
pendingMessagesUpdater.incrementAndGet(this);
if (ctx.eventLoop().inEventLoop()) {
doSendMessage(message);
} else {
ctx.eventLoop().submit(() -> doSendMessage(message));
}
}
代码示例来源:origin: redisson/redisson
private void runFinishPeerReadTask(final LocalChannel peer) {
// If the peer is writing, we must wait until after reads are completed for that peer before we can read. So
// we keep track of the task, and coordinate later that our read can't happen until the peer is done.
final Runnable finishPeerReadTask = new Runnable() {
@Override
public void run() {
finishPeerRead0(peer);
}
};
try {
if (peer.writeInProgress) {
peer.finishReadFuture = peer.eventLoop().submit(finishPeerReadTask);
} else {
peer.eventLoop().execute(finishPeerReadTask);
}
} catch (Throwable cause) {
logger.warn("Closing Local channels {}-{} because exception occurred!", this, peer, cause);
close();
peer.close();
PlatformDependent.throwException(cause);
}
}
代码示例来源:origin: line/armeria
@Test
public void messageReadAfterClose_byteBuf() {
call.close(Status.ABORTED, new Metadata());
// messageRead is always called from the event loop.
eventLoop.get().submit(() -> {
call.messageRead(new ByteBufOrStream(GrpcTestUtil.requestByteBuf()));
verify(listener, never()).onMessage(any());
}).syncUninterruptibly();
}
代码示例来源:origin: line/armeria
@Test
public void messageReadAfterClose_stream() {
call.close(Status.ABORTED, new Metadata());
// messageRead is always called from the event loop.
eventLoop.get().submit(() -> {
call.messageRead(new ByteBufOrStream(new ByteBufInputStream(GrpcTestUtil.requestByteBuf(), true)));
verify(listener, never()).onMessage(any());
}).syncUninterruptibly();
}
代码示例来源:origin: line/armeria
@After
public void tearDown() {
// HttpStreamReader must be invoked from an event loop.
eventLoop.get().submit(() -> call.messageReader().cancel()).syncUninterruptibly();
if (!call.isCloseCalled()) {
call.close(Status.OK, new Metadata());
}
}
内容来源于网络,如有侵权,请联系作者删除!