-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Consider the following code:
Any2OneChannel<String> cc = Channel.<String> any2one(5);
AltingChannelInput<String> ci = cc.in();
ChannelOutput<String> co = cc.out();
new Parallel(new CSProcess[]{
() -> {
System.out.println("--> blah");
co.write("blah");
System.out.println("<-- blah");
}, () -> {
try {
Thread.sleep(10);
} catch (InterruptedException ex) {
Logger.getLogger(BlockingPoisonBug.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("--> poison");
co.poison(10);
System.out.println("<-- poison");
}
}).run();
System.out.println("done");
co.write("blah")
occurs and blocks, then co.poison(10)
occurs and blocks, too. I wasn't expecting poison
to block. Is this expected behavior? After some thought, I suppose it's possible that it's intended to act like a poison pill - a normal message that poisons the channel once consumed. It thus blocks where a normal message would block, as long as it isn't the only message in the queue...actually, that's not quite right, either. If I write, poison, write, then read, read, read, the poison isn't read/activated until the third attempt. What are the semantics of poison actually supposed to be?
Metadata
Metadata
Assignees
Labels
No labels