Do fibers have priorities?
Fibers are defined as lightweight threads, and threads have priorities because they are preemptively s开发者_开发技巧cheduled. However, since fibers are cooperative do they too have priorities?
No, they intrinsically don't have priorities, as in cooperative multi-tasking, the context switch target is always determined by the piece of code handing off control (e.g. calling Fiber.yield(), or however it might be called in your implementation).
This doesn't keep you from implementing a scheduler to determine the next switching at the application level, though, which could then decide based on a priority again.
精彩评论