Debian Codegraph @

src/runtime/note_other.go

raw
1 // Copyright 2024 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 !js
6
7 package runtime
8
9 // sleep and wakeup on one-time events.
10 // before any calls to notesleep or notewakeup,
11 // must call noteclear to initialize the Note.
12 // then, exactly one thread can call notesleep
13 // and exactly one thread can call notewakeup (once).
14 // once notewakeup has been called, the notesleep
15 // will return. future notesleep will return immediately.
16 // subsequent noteclear must be called only after
17 // previous notesleep has returned, e.g. it's disallowed
18 // to call noteclear straight after notewakeup.
19 //
20 // notetsleep is like notesleep but wakes up after
21 // a given number of nanoseconds even if the event
22 // has not yet happened. if a goroutine uses notetsleep to
23 // wake up early, it must wait to call noteclear until it
24 // can be sure that no other goroutine is calling
25 // notewakeup.
26 //
27 // notesleep/notetsleep are generally called on g0,
28 // notetsleepg is similar to notetsleep but is called on user g.
29 type note struct {
30 // Futex-based impl treats it as uint32 key,
31 // while sema-based impl as M* waitm.
32 key uintptr
33 }