MCPcopy Create free account
hub / github.com/grpc/grpc-java / wrap

Method wrap

api/src/context/java/io/grpc/Context.java:560–572  ·  view source on GitHub ↗

Wrap a Runnable so that it executes with this context as the #current context.

(final Runnable r)

Source from the content-addressed store, hash-verified

558 * Wrap a {@link Runnable} so that it executes with this context as the {@link #current} context.
559 */
560 public Runnable wrap(final Runnable r) {
561 return new Runnable() {
562 @Override
563 public void run() {
564 Context previous = attach();
565 try {
566 r.run();
567 } finally {
568 detach(previous);
569 }
570 }
571 };
572 }
573
574 /**
575 * Wrap a {@link Callable} so that it executes with this context as the {@link #current} context.

Callers 2

testWrapRunnableMethod · 0.95
testWrapCallableMethod · 0.95

Calls

no outgoing calls

Tested by 2

testWrapRunnableMethod · 0.76
testWrapCallableMethod · 0.76