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