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

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

Introduction

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

Prototype

public final void set(V value) 

Source Link

Document

Set the 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.
 *//*from w w  w  .j  a  va 2  s.  c  om*/
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();
        }
    });
}