/** * Cancel this context and detach it as the current context from the thread. * * @param toAttach context to make current. * @param cause of cancellation, can be {@code null}. */ public void detachAndCancel(Context toAttach, @Nullable Throwable cause) { try { detach(toAttach); } finally { cancel(cause); } }