[java] support creating an actor with parameters (#2817)

Previously `Ray.createActor` only support creating an actor without any parameter. This PR adds the support for creating an actor with parameters. Moreover, besides using a constructor, it's now also allowed to create an actor with a factory method. For more usage, prefer refer to `ActorTest.java`.
This commit is contained in:
Hao Chen
2018-09-04 00:53:03 +08:00
committed by Robert Nishihara
parent b37a283053
commit 9d655721e5
27 changed files with 1131 additions and 680 deletions
@@ -14,7 +14,7 @@ public class Exercise05 {
try {
Ray.init();
// `Ray.createActor` creates an actor instance.
RayActor<Adder> adder = Ray.createActor(Adder.class);
RayActor<Adder> adder = Ray.createActor(Adder::new, 0);
// Use `Ray.call(actor, parameters)` to call an actor method.
RayObject<Integer> result1 = Ray.call(Adder::add, adder, 1);
System.out.println(result1.get());
@@ -34,8 +34,8 @@ public class Exercise05 {
@RayRemote
public static class Adder {
public Adder() {
sum = 0;
public Adder(int initValue) {
sum = initValue;
}
public int add(int n) {