Soo i wanna desigin my own coroutine stuff for something along the lines of
T wait_for_packet_id(int id)
{
}
task<void> process()
{
//if some more data is needed
co_await wait_for_packet_id(123);
co_return
}
void main_loop()
{
while (true)
{
auto data = read_data_from_network();
if(data.id)
{
//wakeup a coroutine (or all on at a time) that waits for it
continue;
}
process();
//if process did not finish maybe add to queue or something
// not yet at this part of the thing
}
}
The issue that i am having is that everyway i look at it, it seems that i need to basically store std::any within task<T>/promise type which (i hope) is not the actual solution of this.
I am aware that wait_for_packet_id needs to "register" itself to a queue/vector of such waiting coroutines and basically map the ids to waiting routines or something that's not really the issue i am having.
The issue is getting the data in.
One other thing i was thinking about is having a custom awaitable that stores the event id and basically have a queue/vector of such ids (inheritance or something) and wake the coroutines that way. but then it seems kinda weird returning event_id& or somethign idk kinda lost