aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/runtime/scheduler.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2021-05-08 20:05:34 +0200
committerRon Evans <[email protected]>2021-05-08 23:08:12 +0200
commit8cd2a462b9190c6615625ce60db8b6b38540c544 (patch)
tree7ce3acc5af8c35f1a37bd8af6bc73f774d531f8f /src/runtime/scheduler.go
parent25b045d0a72d33b934db7279fe516ef16060a771 (diff)
downloadtinygo-8cd2a462b9190c6615625ce60db8b6b38540c544.tar.gz
tinygo-8cd2a462b9190c6615625ce60db8b6b38540c544.zip
runtime: remove the asyncScheduler constant
There is no reason to specialize this per chip as it is only ever used for JavaScript. Not only that, it is causing confusion and is yet another quirk to learn when porting the runtime to a new microcontroller.
Diffstat (limited to 'src/runtime/scheduler.go')
-rw-r--r--src/runtime/scheduler.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/runtime/scheduler.go b/src/runtime/scheduler.go
index 42cc0fef8..c5286d33b 100644
--- a/src/runtime/scheduler.go
+++ b/src/runtime/scheduler.go
@@ -20,6 +20,10 @@ import (
const schedulerDebug = false
+// On JavaScript, we can't do a blocking sleep. Instead we have to return and
+// queue a new scheduler invocation using setTimeout.
+const asyncScheduler = GOOS == "js"
+
var schedulerDone bool
// Queues used by the scheduler.
@@ -138,6 +142,7 @@ func scheduler() {
if t == nil {
if sleepQueue == nil {
if asyncScheduler {
+ // JavaScript is treated specially, see below.
return
}
waitForEvents()
@@ -154,7 +159,8 @@ func scheduler() {
if asyncScheduler {
// The sleepTicks function above only sets a timeout at which
// point the scheduler will be called again. It does not really
- // sleep.
+ // sleep. So instead of sleeping, we return and expect to be
+ // called again.
break
}
continue