Closed etorth closed 3 years ago
Hi @etorth :-)
But currently the libaco bind the coroutine to a
main co
and have to resume by the same thread.
Yes.
Is there any possibility to support it?
Yes again, it is possible to support it from the perspective of technique. But I don't think it is quite necessary, at least in the recent period. But if you do have some very strong reasons, I would be very glad to discuss it with you further.
Here is some advice:
You could just send a msg like (task_fp, task_data_ptr)
to the coroutine you want to execute the task no matter these coroutines (i.e. the sender and receiver) are from the same thread or not. Or you could simply treat the coroutine as a service which could receive request msg and reply with the result msg.
Or maybe you could give Golang a try about the thing you wanna do? :-p
https://github.com/zswDev/libgco/blob/master/task.cpp
change aco->main_co = thread_local main_co
I have switched to c++20's native coroutine support.
I am using the actor model, actor get scheduled and ran in thread pool.
Means to use a coroutine, it can be yield by any thread of the pool, and then resumed by any thread of the pool. But currently the libaco bind the coroutine to a ``main co" and have to resume by same thread. Is there any possibility to support it?