use of io.servicetalk.context.api.ContextMap in project servicetalk by apple.
the class ContextPreservingRunnable method run.
@Override
public void run() {
final Thread currentThread = Thread.currentThread();
if (currentThread instanceof ContextMapHolder) {
final ContextMapHolder asyncContextMapHolder = (ContextMapHolder) currentThread;
ContextMap prev = asyncContextMapHolder.context();
try {
asyncContextMapHolder.context(saved);
delegate.run();
} finally {
asyncContextMapHolder.context(prev);
}
} else {
slowPath();
}
}
use of io.servicetalk.context.api.ContextMap in project servicetalk by apple.
the class ContextPreservingSubscriber method onErrorSlowPath.
private void onErrorSlowPath(Throwable t) {
ContextMap prev = CONTEXT_THREAD_LOCAL.get();
try {
CONTEXT_THREAD_LOCAL.set(saved);
subscriber.onError(t);
} finally {
CONTEXT_THREAD_LOCAL.set(prev);
}
}
use of io.servicetalk.context.api.ContextMap in project servicetalk by apple.
the class ContextPreservingSubscriber method onNext.
@Override
public final void onNext(T t) {
final Thread currentThread = Thread.currentThread();
if (currentThread instanceof ContextMapHolder) {
final ContextMapHolder asyncContextMapHolder = (ContextMapHolder) currentThread;
ContextMap prev = asyncContextMapHolder.context();
try {
asyncContextMapHolder.context(saved);
subscriber.onNext(t);
} finally {
asyncContextMapHolder.context(prev);
}
} else {
onNextSlowPath(t);
}
}
use of io.servicetalk.context.api.ContextMap in project servicetalk by apple.
the class ContextPreservingSubscription method requestSlowPath.
private void requestSlowPath(long l) {
ContextMap prev = CONTEXT_THREAD_LOCAL.get();
try {
CONTEXT_THREAD_LOCAL.set(saved);
subscription.request(l);
} finally {
CONTEXT_THREAD_LOCAL.set(prev);
}
}
use of io.servicetalk.context.api.ContextMap in project servicetalk by apple.
the class ContextPreservingSingleSubscriber method onErrorSlowPath.
private void onErrorSlowPath(Throwable t) {
ContextMap prev = CONTEXT_THREAD_LOCAL.get();
try {
CONTEXT_THREAD_LOCAL.set(saved);
subscriber.onError(t);
} finally {
CONTEXT_THREAD_LOCAL.set(prev);
}
}
Aggregations