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

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

Introduction

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

Prototype

public final void remove() 

Source Link

Document

Sets the value to uninitialized; a proceeding call to get() will trigger a call to initialValue().

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 ww  w.ja  va2 s  .  c  o 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();
        }
    });
}