use of io.servicetalk.context.api.ContextMapHolder in project servicetalk by apple.
the class ContextPreservingCompletableSubscriber method onComplete.
@Override
public final void onComplete() {
final Thread currentThread = Thread.currentThread();
if (currentThread instanceof ContextMapHolder) {
final ContextMapHolder asyncContextMapHolder = (ContextMapHolder) currentThread;
ContextMap prev = asyncContextMapHolder.context();
try {
asyncContextMapHolder.context(saved);
subscriber.onComplete();
} finally {
asyncContextMapHolder.context(prev);
}
} else {
onCompleteSlowPath();
}
}
use of io.servicetalk.context.api.ContextMapHolder in project servicetalk by apple.
the class ContextPreservingCompletableSubscriber method onError.
@Override
public final void onError(Throwable t) {
final Thread currentThread = Thread.currentThread();
if (currentThread instanceof ContextMapHolder) {
final ContextMapHolder asyncContextMapHolder = (ContextMapHolder) currentThread;
ContextMap prev = asyncContextMapHolder.context();
try {
asyncContextMapHolder.context(saved);
subscriber.onError(t);
} finally {
asyncContextMapHolder.context(prev);
}
} else {
onErrorSlowPath(t);
}
}
use of io.servicetalk.context.api.ContextMapHolder in project servicetalk by apple.
the class ContextPreservingConsumer method accept.
@Override
public void accept(T t) {
final Thread currentThread = Thread.currentThread();
if (currentThread instanceof ContextMapHolder) {
final ContextMapHolder asyncContextMapHolder = (ContextMapHolder) currentThread;
ContextMap prev = asyncContextMapHolder.context();
try {
asyncContextMapHolder.context(saved);
delegate.accept(t);
} finally {
asyncContextMapHolder.context(prev);
}
} else {
slowPath(t);
}
}
use of io.servicetalk.context.api.ContextMapHolder 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.ContextMapHolder 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);
}
}
Aggregations