mirror of
https://github.com/wassname/ray.git
synced 2026-07-03 17:32:29 +08:00
Support multiple core workers in one process (#7623)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user