public static void set(WebContext webContext) { WEB_CONTEXT_THREAD_LOCAL.set(webContext); }
public static void set(WebContext webContext) { WEB_CONTEXT_THREAD_LOCAL.set(webContext); }
@Override public void run() { if (child instanceof EventLoop) { self.set((EventLoop) child); } } }); // Since this is an optimization, there is no need for us to wait for this task to finish.
@Override public void run() { perElHolder.set(newHolder); } });
static void set(RequestContext ctx) { context.set(ctx); }
public static WebContext create(Request request, Response response, ChannelHandlerContext ctx) { WebContext webContext = new WebContext(); webContext.request = request; webContext.response = response; webContext.channelHandlerContext = ctx; WEB_CONTEXT_THREAD_LOCAL.set(webContext); return webContext; }
public static WebContext create(Request request, Response response, ChannelHandlerContext ctx) { WebContext webContext = new WebContext(); webContext.request = request; webContext.response = response; webContext.channelHandlerContext = ctx; WEB_CONTEXT_THREAD_LOCAL.set(webContext); return webContext; }
@Override public Marshaller getMarshaller(ChannelHandlerContext ctx) throws Exception { Marshaller marshaller = marshallers.get(); if (marshaller == null) { marshaller = factory.createMarshaller(config); marshallers.set(marshaller); } return marshaller; } }
@Override public Unmarshaller getUnmarshaller(ChannelHandlerContext ctx) throws Exception { Unmarshaller unmarshaller = unmarshallers.get(); if (unmarshaller == null) { unmarshaller = factory.createUnmarshaller(config); unmarshallers.set(unmarshaller); } return unmarshaller; }
@Override public Marshaller getMarshaller(ChannelHandlerContext ctx) throws Exception { Marshaller marshaller = marshallers.get(); if (marshaller == null) { marshaller = factory.createMarshaller(config); marshallers.set(marshaller); } return marshaller; } }
@Override public Unmarshaller getUnmarshaller(ChannelHandlerContext ctx) throws Exception { Unmarshaller unmarshaller = unmarshallers.get(); if (unmarshaller == null) { unmarshaller = factory.createUnmarshaller(config); unmarshallers.set(unmarshaller); } return unmarshaller; }
@Override public void execute(Runnable command) { if (command == null) { throw new NullPointerException("command"); } if (!RUNNING.get()) { RUNNING.set(true); try { command.run(); } catch (Throwable cause) { logger.info("Throwable caught while executing Runnable {}", command, cause); } finally { Queue<Runnable> delayedRunnables = DELAYED_RUNNABLES.get(); Runnable runnable; while ((runnable = delayedRunnables.poll()) != null) { try { runnable.run(); } catch (Throwable cause) { logger.info("Throwable caught while executing Runnable {}", runnable, cause); } } RUNNING.set(false); } } else { DELAYED_RUNNABLES.get().add(command); } }
@Nullable @SuppressWarnings("unchecked") static <T extends RequestContext> T getAndSet(RequestContext ctx) { final InternalThreadLocalMap map = InternalThreadLocalMap.get(); final RequestContext oldCtx = context.get(map); context.set(map, ctx); return (T) oldCtx; }
@Override public void execute(Runnable command) { if (command == null) { throw new NullPointerException("command"); } if (!RUNNING.get()) { RUNNING.set(true); try { command.run(); } catch (Throwable cause) { logger.info("Throwable caught while executing Runnable {}", command, cause); } finally { Queue<Runnable> delayedRunnables = DELAYED_RUNNABLES.get(); Runnable runnable; while ((runnable = delayedRunnables.poll()) != null) { try { runnable.run(); } catch (Throwable cause) { logger.info("Throwable caught while executing Runnable {}", runnable, cause); } } RUNNING.set(false); } } else { DELAYED_RUNNABLES.get().add(command); } }
@Override public Unmarshaller getUnmarshaller(ChannelHandlerContext ctx) throws Exception { Unmarshaller unmarshaller = unmarshallers.get(); if (unmarshaller == null) { unmarshaller = factory.createUnmarshaller(config); unmarshallers.set(unmarshaller); } return unmarshaller; }
@Override public Marshaller getMarshaller(ChannelHandlerContext ctx) throws Exception { Marshaller marshaller = marshallers.get(); if (marshaller == null) { marshaller = factory.createMarshaller(config); marshallers.set(marshaller); } return marshaller; } }
/** Read a {@code bytes} field value from the stream. */ public ByteString readBytes() throws IOException { final int size = readRawVarint32(); if (size == 0) { return ByteString.EMPTY; } else { byte[] localBuf = localByteArray.get(); if (localBuf == null || localBuf.length < size) { localBuf = new byte[Math.max(size, 1024)]; localByteArray.set(localBuf); } buf.readBytes(localBuf, 0, size); ByteString res = ByteString.copyFrom(localBuf, 0, size); return res; } }
@Override public void execute(Runnable command) { if (command == null) { throw new NullPointerException("command"); } if (!RUNNING.get()) { RUNNING.set(true); try { command.run(); } catch (Throwable cause) { logger.info("Throwable caught while executing Runnable {}", command, cause); } finally { Queue<Runnable> delayedRunnables = DELAYED_RUNNABLES.get(); Runnable runnable; while ((runnable = delayedRunnables.poll()) != null) { try { runnable.run(); } catch (Throwable cause) { logger.info("Throwable caught while executing Runnable {}", runnable, cause); } } RUNNING.set(false); } } else { DELAYED_RUNNABLES.get().add(command); } }
/** Write a byte string. */ public void writeRawBytes(final ByteString value) throws IOException { byte[] localBuf = localByteArray.get(); if (localBuf == null || localBuf.length < value.size()) { localBuf = new byte[Math.max(value.size(), 1024)]; localByteArray.set(localBuf); } value.copyTo(localBuf, 0); buf.writeBytes(localBuf, 0, value.size()); }
if (neededSpace > nioBuffers.length) { nioBuffers = expandNioBufferArray(nioBuffers, neededSpace, nioBufferCount); NIO_BUFFERS.set(threadLocalMap, nioBuffers);