Support multiple core workers in one process (#7623)

This commit is contained in:
Kai Yang
2020-04-07 11:01:47 +08:00
committed by GitHub
parent e91595f955
commit 48b48cc8c2
90 changed files with 2014 additions and 1411 deletions
+7 -2
View File
@@ -44,7 +44,7 @@ public final class Ray extends RayCall {
/**
* Shutdown Ray runtime.
*/
public static void shutdown() {
public static synchronized void shutdown() {
if (runtime != null) {
runtime.shutdown();
runtime = null;
@@ -137,6 +137,11 @@ public final class Ray extends RayCall {
runtime.setAsyncContext(asyncContext);
}
// TODO (kfstorm): add the `rollbackAsyncContext` API to allow rollbacking the async context of
// the current thread to the one before `setAsyncContext` is called.
// TODO (kfstorm): unify the `wrap*` methods.
/**
* If users want to use Ray API in their own threads, they should wrap their {@link Runnable}
* objects with this method.
@@ -155,7 +160,7 @@ public final class Ray extends RayCall {
* @param callable The callable to wrap.
* @return The wrapped callable.
*/
public static Callable wrapCallable(Callable callable) {
public static <T> Callable<T> wrapCallable(Callable<T> callable) {
return runtime.wrapCallable(callable);
}
@@ -159,6 +159,7 @@ public interface RayRuntime {
/**
* Wrap a {@link Runnable} with necessary context capture.
*
* @param runnable The runnable to wrap.
* @return The wrapped runnable.
*/
@@ -166,8 +167,9 @@ public interface RayRuntime {
/**
* Wrap a {@link Callable} with necessary context capture.
*
* @param callable The callable to wrap.
* @return The wrapped callable.
*/
Callable wrapCallable(Callable callable);
<T> Callable<T> wrapCallable(Callable<T> callable);
}