1// Copyright 2013 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5//go:build plan9 6 7package runtime 8 9import "internal/runtime/atomic" 10 11var netpollInited atomic.Uint32 12 13var netpollStubLock mutex 14var netpollNote note 15 16// netpollBroken, protected by netpollBrokenLock, avoids a double notewakeup. 17var netpollBrokenLock mutex 18var netpollBroken bool 19 20func netpollGenericInit() { 21 netpollInited.Store(1) 22} 23 24func netpollBreak() { 25 lock(&netpollBrokenLock) 26 broken := netpollBroken 27 netpollBroken = true 28 if !broken { 29 notewakeup(&netpollNote) 30 } 31 unlock(&netpollBrokenLock) 32} 33 34// Polls for ready network connections. 35// Returns list of goroutines that become runnable. 36func netpoll(delay int64) (gList, int32) { 37 // Implementation for platforms that do not support 38 // integrated network poller. 39 if delay != 0 { 40 // This lock ensures that only one goroutine tries to use 41 // the note. It should normally be completely uncontended. 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 // Guard against starvation in case the lock is contended 52 // (eg when running TestNetpollBreak). 53 osyield() 54 } 55 return gList{}, 0 56} 57 58func netpollinited() bool { 59 return netpollInited.Load() != 0 60} 61 62func netpollAnyWaiters() bool { 63 return false 64} 65 66func netpollAdjustWaiters(delta int32) { 67} 68