ApolloAuto / apollo

An open autonomous driving platform
Apache License 2.0
25.13k stars 9.71k forks source link

How to schedule co-routines acros different processes? #14573

Open lovelydett opened 2 years ago

lovelydett commented 2 years ago

I notice the actual task (Component::Process) is wrapped with a lambda and passed to the coroutine factory as described in component.h, allowing for the scheduler to create a task based on the component name and the task function.

But I assume that each component is loaded by a separate mainborad process upon launch, and the intended component object is created within that process, along with other util classes that support CyberRT (e.g., scheduler).

I wonder if the schedulers are isolated across the processes though being singleton within its process. How can the task functions (XXXComponent::Proc) from different processes be co-scheduled in the form of co-routines?

Thanks for you reply!

lovelydett commented 2 years ago

And what if the task function itself is multi-thread? Are the threads it creates also handled by the scheduler as co-routine tasks?