[libmill] broadcast effect

  • From: Alex Silvera <alex.silvera@xxxxxxxxx>
  • To: "libmill@xxxxxxxxxxxxx" <libmill@xxxxxxxxxxxxx>
  • Date: Sat, 11 Jul 2015 06:58:34 +0000 (UTC)

Hello,
My expectation for this little test was for all the receivers to get 42!
However, it is observed that only receiver 1 gets the message. Is my
expectation incorrect? How can one create a broadcast message?

void sender(chan ch) {
    printf("Sender sending...\n");    msleep(1000);
    chs(ch, int, 42);
}

void reciever1(chan ch) {
  choose {
      in(ch, int, val):
      printf("Reciever 1 recieved %d\n", val);
      end
  }
}

void reciever2(chan ch) {
  choose {
      in(ch, int, val):
      printf("Reciever 2 recieved %d\n", val);
      end
  }
}

void reciever3(chan ch) {
  choose {
      in(ch, int, val):
      printf("Reciever 2 recieved %d\n", val);
      end
  }
}

int main() {
    chan ch = chmake(int, 0);
    go(sender(chdup(ch)));
    go(reciever1(chdup(ch)));
    go(reciever2(chdup(ch)));
    go(reciever3(chdup(ch)));
    msleep(10000);
    return 0;
}
Thanks


Other related posts: