aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/note_js.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/note_js.go')
-rw-r--r--src/runtime/note_js.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/runtime/note_js.go b/src/runtime/note_js.go
new file mode 100644
index 0000000000..be43fa42b0
--- /dev/null
+++ b/src/runtime/note_js.go
@@ -0,0 +1,40 @@
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package runtime
+
+// sleep and wakeup on one-time events.
+// before any calls to notesleep or notewakeup,
+// must call noteclear to initialize the Note.
+// then, exactly one thread can call notesleep
+// and exactly one thread can call notewakeup (once).
+// once notewakeup has been called, the notesleep
+// will return. future notesleep will return immediately.
+// subsequent noteclear must be called only after
+// previous notesleep has returned, e.g. it's disallowed
+// to call noteclear straight after notewakeup.
+//
+// notetsleep is like notesleep but wakes up after
+// a given number of nanoseconds even if the event
+// has not yet happened. if a goroutine uses notetsleep to
+// wake up early, it must wait to call noteclear until it
+// can be sure that no other goroutine is calling
+// notewakeup.
+//
+// notesleep/notetsleep are generally called on g0,
+// notetsleepg is similar to notetsleep but is called on user g.
+type note struct {
+ status int32
+
+ // The G waiting on this note.
+ gp *g
+
+ // Deadline, if any. 0 indicates no timeout.
+ deadline int64
+
+ // allprev and allnext are used to form the allDeadlineNotes linked
+ // list. These are unused if there is no deadline.
+ allprev *note
+ allnext *note
+}