...
Source file
src/runtime/netpoll_stub.go
Documentation: runtime
1
2
3
4
5
6
7 package runtime
8
9 import "internal/runtime/atomic"
10
11 var netpollInited atomic.Uint32
12
13 var netpollStubLock mutex
14 var netpollNote note
15
16
17 var netpollBrokenLock mutex
18 var netpollBroken bool
19
20 func netpollGenericInit() {
21 netpollInited.Store(1)
22 }
23
24 func netpollBreak() {
25 lock(&netpollBrokenLock)
26 broken := netpollBroken
27 netpollBroken = true
28 if !broken {
29 notewakeup(&netpollNote)
30 }
31 unlock(&netpollBrokenLock)
32 }
33
34
35
36 func netpoll(delay int64) (gList, int32) {
37
38
39 if delay != 0 {
40
41
42 lock(&netpollStubLock)
43
44 lock(&netpollBrokenLock)
45 noteclear(&netpollNote)
46 netpollBroken = false
47 unlock(&netpollBrokenLock)
48
49 notetsleep(&netpollNote, delay)
50 unlock(&netpollStubLock)
51
52
53 osyield()
54 }
55 return gList{}, 0
56 }
57
58 func netpollinited() bool {
59 return netpollInited.Load() != 0
60 }
61
62 func netpollAnyWaiters() bool {
63 return false
64 }
65
66 func netpollAdjustWaiters(delta int32) {
67 }
68
View as plain text