Exception in Fiber "fiber-10000002" co.paralleluniverse.strands.queues.QueueCapacityExceededException
with the BLOCK overflow policy specified. Small test case is attached. Am I doing something inherently wrong?
import co.paralleluniverse.actors.Actor;
import co.paralleluniverse.actors.ActorRef;
import co.paralleluniverse.actors.BasicActor;
import co.paralleluniverse.actors.MailboxConfig;
import co.paralleluniverse.fibers.Fiber;
import co.paralleluniverse.fibers.FiberForkJoinScheduler;
import co.paralleluniverse.fibers.FiberScheduler;
import co.paralleluniverse.fibers.SuspendExecution;
import co.paralleluniverse.strands.channels.Channels;
public class ActorTest {
public static void main(String[] args) throws Exception {
final ActorRef a = spawnActor(new BasicActor<Message, Void>(new MailboxConfig(10, Channels.OverflowPolicy.BLOCK)) {
@Override
protected Void doRun() throws InterruptedException, SuspendExecution {
while (true) {
Message m = receive();
long recv = System.nanoTime();
System.out.println(m.num + " current: " + recv + " Sent: " + m.content + "diff: " + (recv - m.content));
}
}
}).ref();
spawnActor(new BasicActor<Integer, Void>(new MailboxConfig(10, Channels.OverflowPolicy.BLOCK)) {
@Override
protected Void doRun() throws InterruptedException, SuspendExecution {
for (int i = 0; i < 100; i++) {
a.send(new Message(i, System.nanoTime()));
}
return null;
}
});
Thread.sleep(1000000);
}
private static <Message, V> Actor<Message, V> spawnActor(Actor<Message, V> actor) {
new Fiber(actor).start();
return actor;
}
static class Message {
public final int num;
public final long content;
public Message(int num, long content) {
this.num = num;
this.content = content;
}
}
}