apollo
apollo copied to clipboard
why cyber rt use for (;;) here?
why cyber rt use for (;;) here? it looks like that it cannot run loop here because the "if, else" cover all the conditions in this loop.
Also I found only this part and io part use yeild code, it is looks like that the coroutines is designed for these two parts. Maybe coroutines not necessary for cyber rt.
Actually, I didn't understand your question. The for loop will wait for data and execute. If there is no data, it will sleep. There is no problem with this.
You can describe your problem in detail for better discussion
I misunderstand the coroutine design in cyber rt in the last time. In the classic scheduler, though cyber rt use the coroutine design, the the classic scheduler don't take advantage of the benefits of concurrency. When the thread get the READY coroutine from MULTI_PRIO_QUEUE, it can get any coroutine every time. This cause a protblem that the callback will be run in random processer thread when we keep running publish and subscribe communication, rather than the callback is run in a same thread. Maybe the design is meant to choreography scheduler?
In the classic scheduler, multiple processors compete for access to a thread-safe coroutine queue (protected by a mutex) where coroutines are prioritized based on their priority levels, with higher-priority coroutines being selected for execution after the competition.
I test it one moth age. If delete the for (;;), the CRoutine will be finished.
This keep the life of the CRoutine. The yeild make the thread jump from the for (;;) to other CRoutine.