aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/internal/task/task.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2024-10-25 11:14:57 +0200
committerRon Evans <[email protected]>2024-11-20 12:45:09 +0100
commitd1fe02df230e1a31ba9ff8f440a5ef33a60d1313 (patch)
tree1cb0d8847b7eb84fb87db0f9fc2200311dcb12d6 /src/internal/task/task.go
parent6593cf22fad6fab2a201ed00c2cc20c76e29161a (diff)
downloadtinygo-d1fe02df230e1a31ba9ff8f440a5ef33a60d1313.tar.gz
tinygo-d1fe02df230e1a31ba9ff8f440a5ef33a60d1313.zip
runtime: move scheduler code around
This moves all scheduler code into a separate file that is only compiled when there's a scheduler in use (the tasks or asyncify scheduler, which are both cooperative). The main goal of this change is to make it easier to add a new "scheduler" based on OS threads. It also fixes a few subtle issues with `-gc=none`: - Gosched() panicked. This is now fixed to just return immediately (the only logical thing to do when there's only one goroutine). - Timers aren't supported without a scheduler, but the relevant code was still present and would happily add a timer to the queue. It just never ran. So now it exits with a runtime error, similar to any blocking operation.
Diffstat (limited to 'src/internal/task/task.go')
-rw-r--r--src/internal/task/task.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/internal/task/task.go b/src/internal/task/task.go
index c1ee57dda..bce65b582 100644
--- a/src/internal/task/task.go
+++ b/src/internal/task/task.go
@@ -33,3 +33,6 @@ func getGoroutineStackSize(fn uintptr) uintptr
//go:linkname runtime_alloc runtime.alloc
func runtime_alloc(size uintptr, layout unsafe.Pointer) unsafe.Pointer
+
+//go:linkname scheduleTask runtime.scheduleTask
+func scheduleTask(*Task)