But streaming chan are not complete async. as reading/writing from an empty channel blocks the control to execute rest of the statements.
I mean when I execute below code, If I don't write to channel, in task1() rest of code followed by read_chan() will not get executed.
Is there a way to achieve complete async. I mean if the channel empty, it should simply ignore and move to the other statements. Or any other way without channels we can do, like with global variables and etc..? Basically, what i want is one task() produces and another one consumes.
Code: Select all
void task1(streaming chanend c){
while(1){
read_chan(c,buf);
//some logic
}
}
void task2(streaming chanend c){
while(1){
//some logic
if(flag){
write_chan(c,buf);
}
//some logic
}
}