Skip to content

Commit 3f8a110

Browse files
aykevldeadprogram
authored andcommitted
runtime: move mainExited boolean
This variable is only necessary on the cooperative and none scheduler. It is not used on the threads scheduler. The reason for moving is that the upcoming multicore baremetal scheduler also needs mainExited but of a different type: an atomic variable instead of a plain boolean.
1 parent 95ee572 commit 3f8a110

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/runtime/scheduler.go

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import "internal/task"
44

55
const schedulerDebug = false
66

7-
var mainExited bool
8-
97
var timerQueue *timerNode
108

119
// Simple logging, for debugging.

src/runtime/scheduler_cooperative.go

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ const hasScheduler = true
2727
// concurrency, it does not have parallelism.
2828
const hasParallelism = false
2929

30+
// Set to true after main.main returns.
31+
var mainExited bool
32+
3033
// Queues used by the scheduler.
3134
var (
3235
runqueue task.Queue

src/runtime/scheduler_none.go

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const hasScheduler = false
99
// No goroutines are allowed, so there's no parallelism anywhere.
1010
const hasParallelism = false
1111

12+
// Set to true after main.main returns.
13+
var mainExited bool
14+
1215
// run is called by the program entry point to execute the go program.
1316
// With the "none" scheduler, init and the main function are invoked directly.
1417
func run() {

0 commit comments

Comments
 (0)