Create an executor that propagates the #current context when Executor#execute is called as the #current context of the Runnable scheduled. Note that this is a static method. @see #fixedContextExecutor(Executor)
(final Executor e)
| 617 | * @see #fixedContextExecutor(Executor) |
| 618 | */ |
| 619 | public static Executor currentContextExecutor(final Executor e) { |
| 620 | final class CurrentContextExecutor implements Executor { |
| 621 | @Override |
| 622 | public void execute(Runnable r) { |
| 623 | e.execute(Context.current().wrap(r)); |
| 624 | } |
| 625 | } |
| 626 | |
| 627 | return new CurrentContextExecutor(); |
| 628 | } |
| 629 | |
| 630 | /** |
| 631 | * A context which inherits cancellation from its parent but which can also be independently |
no outgoing calls