You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class A
{
void MainLoop();
private:
coroutine::Channel ch1_;
coroutine::Channel ch2_;
};
void A::MainLoop()
{
auto f = &{ch2_.push(1);};
auto co1 = coroutine::create(f);
ch1_.consumer(co1);
auto f2 = &{ch2.pop();};
auto co2 = coroutine::create(f2)
ch2_.consumer(co2);
while(1)
{
coroutine::resume(co1);
coroutine::resume(co2);
}
}
i find that,when i call ch2_.push, it will aborted!I don't know is it a bug or it does not allow using like this.
Channel design pattern works like:
mainloop call push() to dispatch an object to one channel, and push() will auto resume coroutine of this channel;
this coroutine pop() and handles an object until it yields itself. when no object in channel, pop() will auto yield this coroutine.
In asymmetric coroutine, one routine is not allowed to resume() another coroutine.
resumt() must be called by mainloop of thread.
Since push() will auto resume coroutine of channel, push() is not allowed to be called in coroutine,
it will trigger assert false in code.
when i use two channel for comunication, call push, it will aborted because of ordinator.current === 0
The text was updated successfully, but these errors were encountered: