Example usage for io.netty.util.concurrent FastThreadLocal get

List of usage examples for io.netty.util.concurrent FastThreadLocal get

Introduction

In this page you can find the example usage for io.netty.util.concurrent FastThreadLocal get.

Prototype

@SuppressWarnings("unchecked")
public final V get() 

Source Link

Document

Returns the current value for the current thread

Usage

From source file:com.linecorp.armeria.internal.tracing.SpanContextUtil.java

License:Apache License

/**
 * Sets up the {@link RequestContext} to push and pop the {@link Span} whenever it is entered/exited.
 *//*  ww  w .  j  av a 2  s .  co m*/
public static void setupContext(FastThreadLocal<SpanInScope> threadLocalSpan, RequestContext ctx, Span span,
        Tracer tracer) {
    ctx.onEnter(unused -> threadLocalSpan.set(tracer.withSpanInScope(span)));
    ctx.onExit(unused -> {
        SpanInScope spanInScope = threadLocalSpan.get();
        if (spanInScope != null) {
            spanInScope.close();
            threadLocalSpan.remove();
        }
    });
}