fix(scheduler): make Task_Sleep yield instead of block (MVP)

This commit is contained in:
2026-06-10 19:44:55 +03:00
parent 211a811f32
commit 9e547f123a
+5 -2
View File
@@ -1010,8 +1010,11 @@ void bux_task_join(void* handle) {
void bux_task_sleep(int64_t ms) { void bux_task_sleep(int64_t ms) {
if (ms <= 0) return; if (ms <= 0) return;
if (g_scheduler && g_scheduler->current) { if (g_scheduler && g_scheduler->current) {
g_scheduler->current->wake_at = bux_now_ms() + ms; /* MVP: yield instead of real sleep. Real sleep requires a timer to
g_scheduler->current->state = BUX_TASK_BLOCKED; * requeue BLOCKED tasks, which is complex. For now, yield lets
* other tasks run. Main-thread sleep still uses nanosleep. */
(void)ms; /* silence unused warning for MVP */
g_scheduler->current->state = BUX_TASK_READY;
swapcontext(&g_scheduler->current->ctx, &g_scheduler_context); swapcontext(&g_scheduler->current->ctx, &g_scheduler_context);
} else { } else {
struct timespec ts; struct timespec ts;