-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathscheduler.go
More file actions
72 lines (61 loc) · 1.52 KB
/
scheduler.go
File metadata and controls
72 lines (61 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package runtime
import "internal/task"
const schedulerDebug = false
var timerQueue *timerNode
// Simple logging, for debugging.
func scheduleLog(msg string) {
if schedulerDebug {
println("---", msg)
}
}
// Simple logging with a task pointer, for debugging.
func scheduleLogTask(msg string, t *task.Task) {
if schedulerDebug {
println("---", msg, t)
}
}
// Simple logging with a channel and task pointer.
func scheduleLogChan(msg string, ch *channel, t *task.Task) {
if schedulerDebug {
println("---", msg, ch, t)
}
}
func timerQueueAdd(tn *timerNode) {
q := &timerQueue
for ; *q != nil; q = &(*q).next {
if tn.whenTicks() < (*q).whenTicks() {
// this will finish earlier than the next - insert here
break
}
}
tn.next = *q
*q = tn
}
func timerQueueRemove(t *timer) bool {
removedTimer := false
for q := &timerQueue; *q != nil; q = &(*q).next {
if (*q).timer == t {
scheduleLog("removed timer")
*q = (*q).next
removedTimer = true
break
}
}
if !removedTimer {
scheduleLog("did not remove timer")
}
return removedTimer
}
// Goexit terminates the currently running goroutine. No other goroutines are affected.
func Goexit() {
panicOrGoexit(nil, panicGoexit)
}
//go:linkname fips_getIndicator crypto/internal/fips140.getIndicator
func fips_getIndicator() uint8 {
return task.Current().FipsIndicator
}
//go:linkname fips_setIndicator crypto/internal/fips140.setIndicator
func fips_setIndicator(indicator uint8) {
// This indicator is stored per goroutine.
task.Current().FipsIndicator = indicator
}