Skip to content

(ChannelOutput).poison(int) blocking #3

@Erhannis

Description

@Erhannis

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions