- Fix link resolution with proper relative/absolute path handling - Improve link styling with underline decoration - Hide leaf nodes from tree, only show directories - Fix log file path for packaged app
712 B
712 B
Thread::Yield
static void Yield()
让出当前线程的时间片,允许操作系统调度器将 CPU 时间分配给其他就绪线程。
参数: 无
返回: 无
复杂度: O(1)
使用场景:
- 在自旋等待某个条件时调用,避免浪费 CPU 周期。
- 在长时间循环中定期让出时间片,提高其他线程的响应性。
示例:
volatile bool ready = false;
Thread worker;
worker.Start([]() {
ready = true;
}, "WorkerThread");
// 忙等待,但定期让出时间片
while (!ready) {
Thread::Yield();
}
worker.Join();