4 karma · joined May 10, 2019 (7y ago) · 1 submissions
comment 7y ago · link · parent
chan_select(2) {
chan_case_send(c, &foo, 0):
do_stuff();
chan_case_recv(c, &bar, 1):
do_other_stuff(bar);
} chan_select_end;
But the implementation (https://github.com/iriri/libcee/blob/master/include/cee/chan...) is both horrifying and not as efficient as just doing the sane thing: chan_case cases[] = {
chan_case(c, CHAN_SEND, &foo), /* unfortunately still a macro but it's basically just a struct literal */
chan_case(c, CHAN_RECV, &bar),
};
switch (chan_alt(cases, 2)) {
case 0:
do_stuff();
break;
case 1:
do_other_stuff(bar);
}