use of io.servicetalk.context.api.ContextMap in project servicetalk by apple.
the class ContextPreservingConsumer method slowPath.
private void slowPath(T t) {
ContextMap prev = CONTEXT_THREAD_LOCAL.get();
try {
CONTEXT_THREAD_LOCAL.set(saved);
delegate.accept(t);
} finally {
CONTEXT_THREAD_LOCAL.set(prev);
}
}
use of io.servicetalk.context.api.ContextMap in project servicetalk by apple.
the class ContextPreservingRunnable method slowPath.
private void slowPath() {
ContextMap prev = CONTEXT_THREAD_LOCAL.get();
try {
CONTEXT_THREAD_LOCAL.set(saved);
delegate.run();
} finally {
CONTEXT_THREAD_LOCAL.set(prev);
}
}
use of io.servicetalk.context.api.ContextMap in project servicetalk by apple.
the class ContextPreservingCancellable method slowPath.
private void slowPath() {
ContextMap prev = CONTEXT_THREAD_LOCAL.get();
try {
CONTEXT_THREAD_LOCAL.set(saved);
delegate.cancel();
} finally {
CONTEXT_THREAD_LOCAL.set(prev);
}
}
use of io.servicetalk.context.api.ContextMap in project servicetalk by apple.
the class ContextPreservingBiConsumer method slowPath.
private void slowPath(T t, U u) {
ContextMap prev = CONTEXT_THREAD_LOCAL.get();
try {
CONTEXT_THREAD_LOCAL.set(saved);
delegate.accept(t, u);
} finally {
CONTEXT_THREAD_LOCAL.set(prev);
}
}
use of io.servicetalk.context.api.ContextMap in project servicetalk by apple.
the class ContextPreservingSingleSubscriber method onSubscribe.
@Override
public final void onSubscribe(Cancellable cancellable) {
final Thread currentThread = Thread.currentThread();
if (currentThread instanceof ContextMapHolder) {
final ContextMapHolder asyncContextMapHolder = (ContextMapHolder) currentThread;
ContextMap prev = asyncContextMapHolder.context();
try {
asyncContextMapHolder.context(saved);
invokeOnSubscribe(cancellable);
} finally {
asyncContextMapHolder.context(prev);
}
} else {
onSubscribeSlowPath(cancellable);
}
}
Aggregations