}
break;
case testGenEvent:
if (i == 1) {
final DelayedVal<String> dv = new DelayedVal<>();
spawnGenEvent(new Initializer() {
@Override
public void init() throws SuspendExecution {
EventSourceActor.currentEventSourceActor().register("myEventServer");
try {
final EventSource<String> ge = LocalActor.self();
ge.addHandler(new EventHandler<String>() {
@Override
public void handleEvent(String event) {
dv.set(event);
System.out.println("sout " + event);
ge.shutdown();
}
});
} catch (InterruptedException ex) {
System.out.println(ex);
}
}
@Override
public void terminate(Throwable cause) throws SuspendExecution {
System.out.println("terminated");
}
});
String get = dv.get();
System.out.println("got msg " + get);
assert get.equals("hello world");
} else {
spawnActor(new BasicActor<Message, Void>() {
protected Void doRun() throws SuspendExecution, InterruptedException {
final EventSource<String> ge = (EventSource) ActorRegistry.getActor("myEventServer");
ge.notify("hello world");
return null;
}
}).join();
}
break;
case testMultiGetActor:
if (i == 1) {
spawnGenEvent(new Initializer() {
AtomicInteger ai = new AtomicInteger();
@Override
public void init() throws SuspendExecution {
Actor.currentActor().register("myEventServer");
try {
final EventSource<String> ge = LocalActor.self();
ge.addHandler(new EventHandler<String>() {
@Override
public void handleEvent(String event) {
System.out.println("msg no " + ai.incrementAndGet() + ": " + event);
}
});
} catch (InterruptedException ex) {
System.out.println(ex);
}
}
@Override
public void terminate(Throwable cause) throws SuspendExecution {
System.out.println("terminated");
}
}).join();
} else {
Queue<Actor> queue = new LinkedList<>();
for (int j = 0; j < 1000; j++) {
final BasicActor<Message, Void> actor = spawnActor(new BasicActor<Message, Void>("actor-" + j) {
protected Void doRun() throws SuspendExecution, InterruptedException {
try {
final EventSource<String> ge = (EventSource) ActorRegistry.getActor("myEventServer");
ge.notify("hwf " + getName());
} catch (Exception e) {
System.out.println("error in " + getName());
throw e;
}
return null;
}
});
queue.add(actor);
// actor.join();
}
for (Actor localActor : queue)
localActor.join();
Thread.sleep(500);
}
break;
case testOrdering:
if (i == 1) {
spawnGenEvent(new Initializer() {
AtomicInteger ai = new AtomicInteger();
@Override
public void init() throws SuspendExecution {
EventSourceActor.currentEventSourceActor().register("myEventServer");