本文整理匯總了Java中io.netty.util.concurrent.EventExecutor.inEventLoop方法的典型用法代碼示例。如果您正苦於以下問題:Java EventExecutor.inEventLoop方法的具體用法?Java EventExecutor.inEventLoop怎麽用?Java EventExecutor.inEventLoop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.netty.util.concurrent.EventExecutor
的用法示例。
在下文中一共展示了EventExecutor.inEventLoop方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: unrecoverableErrorOccurred
import io.netty.util.concurrent.EventExecutor; //導入方法依賴的package包/類
@Override
public void unrecoverableErrorOccurred(Throwable error, boolean guaranteesBrokenDownstreamResponse) {
// Cancel request streaming so it stops trying to send data downstream and releases any chunks we've been
// holding onto. This holds true no matter the value of guaranteesBrokenDownstreamResponse
// (i.e. we want to stop sending data downstream no matter what). Note that this does not stop the
// downstream call's response, and that is intentional to support use cases where the downstream
// system can still successfully send a full response even though the request wasn't fully sent.
proxyRouterProcessingState.cancelRequestStreaming(error, ctx);
setDownstreamCallTimeOnRequestAttributesIfNotAlreadyDone();
EventExecutor executor = ctx.executor();
if (executor.inEventLoop()) {
sendUnrecoverableErrorDownPipeline(error, guaranteesBrokenDownstreamResponse);
}
else {
executor.execute(() -> sendUnrecoverableErrorDownPipeline(error, guaranteesBrokenDownstreamResponse));
}
}
示例2: renegotiate
import io.netty.util.concurrent.EventExecutor; //導入方法依賴的package包/類
/**
* Performs TLS renegotiation.
*/
public Future<Channel> renegotiate(final Promise<Channel> promise) {
if (promise == null) {
throw new NullPointerException("promise");
}
ChannelHandlerContext ctx = this.ctx;
if (ctx == null) {
throw new IllegalStateException();
}
EventExecutor executor = ctx.executor();
if (!executor.inEventLoop()) {
executor.execute(new OneTimeTask() {
@Override
public void run() {
handshake(promise);
}
});
return promise;
}
handshake(promise);
return promise;
}
示例3: fireChannelRegistered
import io.netty.util.concurrent.EventExecutor; //導入方法依賴的package包/類
@Override
public ChannelHandlerContext fireChannelRegistered() {
final AbstractChannelHandlerContext next = findContextInbound();
EventExecutor executor = next.executor();
if (executor.inEventLoop()) {
next.invokeChannelRegistered();
} else {
executor.execute(new OneTimeTask() {
@Override
public void run() {
next.invokeChannelRegistered();
}
});
}
return this;
}
示例4: close
import io.netty.util.concurrent.EventExecutor; //導入方法依賴的package包/類
@Override
public ChannelFuture close(final ChannelPromise promise) {
ChannelHandlerContext ctx = ctx();
EventExecutor executor = ctx.executor();
if (executor.inEventLoop()) {
return finishEncode(ctx, promise);
} else {
final ChannelPromise p = ctx.newPromise();
executor.execute(new Runnable() {
@Override
public void run() {
ChannelFuture f = finishEncode(ctx(), p);
f.addListener(new ChannelPromiseNotifier(promise));
}
});
return p;
}
}
示例5: fireChannelInactive
import io.netty.util.concurrent.EventExecutor; //導入方法依賴的package包/類
@Override
public ChannelHandlerContext fireChannelInactive() {
final AbstractChannelHandlerContext next = findContextInbound();
EventExecutor executor = next.executor();
if (executor.inEventLoop()) {
next.invokeChannelInactive();
} else {
executor.execute(new OneTimeTask() {
@Override
public void run() {
next.invokeChannelInactive();
}
});
}
return this;
}
示例6: fireUserEventTriggered
import io.netty.util.concurrent.EventExecutor; //導入方法依賴的package包/類
@Override
public ChannelHandlerContext fireUserEventTriggered(final Object event) {
if (event == null) {
throw new NullPointerException("event");
}
final AbstractChannelHandlerContext next = findContextInbound();
EventExecutor executor = next.executor();
if (executor.inEventLoop()) {
next.invokeUserEventTriggered(event);
} else {
executor.execute(new OneTimeTask() {
@Override
public void run() {
next.invokeUserEventTriggered(event);
}
});
}
return this;
}
示例7: fireChannelRead
import io.netty.util.concurrent.EventExecutor; //導入方法依賴的package包/類
@Override
public ChannelHandlerContext fireChannelRead(final Object msg) {
if (msg == null) {
throw new NullPointerException("msg");
}
invokedNextChannelRead = true;
final AbstractChannelHandlerContext next = findContextInbound();
EventExecutor executor = next.executor();
if (executor.inEventLoop()) {
next.invokeChannelRead(msg);
} else {
executor.execute(new OneTimeTask() {
@Override
public void run() {
next.invokeChannelRead(msg);
}
});
}
return this;
}
示例8: bind
import io.netty.util.concurrent.EventExecutor; //導入方法依賴的package包/類
@Override
public ChannelFuture bind(final SocketAddress localAddress, final ChannelPromise promise) {
if (localAddress == null) {
throw new NullPointerException("localAddress");
}
if (!validatePromise(promise, false)) {
// cancelled
return promise;
}
final AbstractChannelHandlerContext next = findContextOutbound();
EventExecutor executor = next.executor();
if (executor.inEventLoop()) {
next.invokeBind(localAddress, promise);
} else {
safeExecute(executor, new OneTimeTask() {
@Override
public void run() {
next.invokeBind(localAddress, promise);
}
}, promise, null);
}
return promise;
}
示例9: close
import io.netty.util.concurrent.EventExecutor; //導入方法依賴的package包/類
@Override
public ChannelFuture close(final ChannelPromise promise) {
if (!validatePromise(promise, false)) {
// cancelled
return promise;
}
final AbstractChannelHandlerContext next = findContextOutbound();
EventExecutor executor = next.executor();
if (executor.inEventLoop()) {
next.invokeClose(promise);
} else {
safeExecute(executor, new OneTimeTask() {
@Override
public void run() {
next.invokeClose(promise);
}
}, promise, null);
}
return promise;
}
示例10: deregister
import io.netty.util.concurrent.EventExecutor; //導入方法依賴的package包/類
@Override
public ChannelFuture deregister(final ChannelPromise promise) {
if (!validatePromise(promise, false)) {
// cancelled
return promise;
}
final AbstractChannelHandlerContext next = findContextOutbound();
EventExecutor executor = next.executor();
if (executor.inEventLoop()) {
next.invokeDeregister(promise);
} else {
safeExecute(executor, new OneTimeTask() {
@Override
public void run() {
next.invokeDeregister(promise);
}
}, promise, null);
}
return promise;
}
示例11: read
import io.netty.util.concurrent.EventExecutor; //導入方法依賴的package包/類
@Override
public ChannelHandlerContext read() {
invokedPrevRead = true;
final AbstractChannelHandlerContext next = findContextOutbound();
EventExecutor executor = next.executor();
if (executor.inEventLoop()) {
next.invokeRead();
} else {
Runnable task = next.invokeReadTask;
if (task == null) {
next.invokeReadTask = task = new Runnable() {
@Override
public void run() {
next.invokeRead();
}
};
}
executor.execute(task);
}
return this;
}
示例12: flush
import io.netty.util.concurrent.EventExecutor; //導入方法依賴的package包/類
@Override
public ChannelHandlerContext flush() {
final AbstractChannelHandlerContext next = findContextOutbound();
EventExecutor executor = next.executor();
if (executor.inEventLoop()) {
next.invokeFlush();
} else {
Runnable task = next.invokeFlushTask;
if (task == null) {
next.invokeFlushTask = task = new Runnable() {
@Override
public void run() {
next.invokeFlush();
}
};
}
safeExecute(executor, task, channel.voidPromise(), null);
}
return this;
}
示例13: destroyUp
import io.netty.util.concurrent.EventExecutor; //導入方法依賴的package包/類
private void destroyUp(AbstractChannelHandlerContext ctx) {
final Thread currentThread = Thread.currentThread();
final AbstractChannelHandlerContext tail = this.tail;
for (;;) {
if (ctx == tail) {
destroyDown(currentThread, tail.prev);
break;
}
final EventExecutor executor = ctx.executor();
if (!executor.inEventLoop(currentThread)) {
final AbstractChannelHandlerContext finalCtx = ctx;
executor.execute(new OneTimeTask() {
@Override
public void run() {
destroyUp(finalCtx);
}
});
break;
}
ctx = ctx.next;
}
}
示例14: checkDeadLock
import io.netty.util.concurrent.EventExecutor; //導入方法依賴的package包/類
@Override
protected void checkDeadLock() {
EventExecutor e = executor();
if (e != null && e != ImmediateEventExecutor.INSTANCE && e.inEventLoop()) {
throw new BlockingOperationException();
}
}
示例15: fireExceptionCaught
import io.netty.util.concurrent.EventExecutor; //導入方法依賴的package包/類
@Override
public ChannelHandlerContext fireExceptionCaught(final Throwable cause) {
if (cause == null) {
throw new NullPointerException("cause");
}
final AbstractChannelHandlerContext next = this.next;
EventExecutor executor = next.executor();
if (executor.inEventLoop()) {
next.invokeExceptionCaught(cause);
} else {
try {
executor.execute(new OneTimeTask() {
@Override
public void run() {
next.invokeExceptionCaught(cause);
}
});
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to submit an exceptionCaught() event.", t);
logger.warn("The exceptionCaught() event that was failed to submit was:", cause);
}
}
}
return this;
}