/** * Sets the runtime associated with the current thread. * <p> * It also tries to set the static runtime if the previous one got garbage collected. * </p> * <p> It's not necessary to "unset" the runtime because: * <ol> * <li>there should normally exist only one (only test cases are expected to have more than one)</li> * <li>it is already a weak reference</li> * <li>if another runtime is using the same thread later (shared thread pools) it will set the runtime before each usage</li> * </ol></p> * * @param runtimeRef a reference to the runtime */ public static void setRuntime(final WeakReference<? extends BasicRuntime> runtimeRef) { if (runtimeRef.get() instanceof ActorRuntime) { final ActorTaskContext context = ActorTaskContext.current(); if (context != null) { context.setRuntime((ActorRuntime) runtimeRef.get()); } } currentRuntime.set(runtimeRef); lastRuntime = runtimeRef; }
})); context.setRuntime(runtime);
/** * Sets the runtime associated with the current thread. * <p> * It also tries to set the static runtime if the previous one got garbage collected. * </p> * <p> It's not necessary to "unset" the runtime because: * <ol> * <li>there should normally exist only one (only test cases are expected to have more than one)</li> * <li>it is already a weak reference</li> * <li>if another runtime is using the same thread later (shared thread pools) it will set the runtime before each usage</li> * </ol></p> * * @param runtimeRef a reference to the runtime */ public static void setRuntime(final WeakReference<? extends BasicRuntime> runtimeRef) { if (runtimeRef.get() instanceof ActorRuntime) { final ActorTaskContext context = ActorTaskContext.current(); if (context != null) { context.setRuntime((ActorRuntime) runtimeRef.get()); } } currentRuntime.set(runtimeRef); lastRuntime = runtimeRef; }