We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 309f111 + 967a856 commit 889a976Copy full SHA for 889a976
src/runtime/cockroach.go
@@ -0,0 +1,12 @@
1
+package runtime
2
+
3
+// CurrentP returns the index of the current P, between 0 and the current
4
+// GOMAXPROCS.
5
+//
6
+// This can only be used as a best-effort facility; there is no guarantee that
7
+// the goroutine still runs on the same P when this function returns.
8
+func CurrentP() int {
9
+ // Note: preemption is not possible in-between these loads (there are no
10
+ // preemption-safe points).
11
+ return int(getg().m.p.ptr().id)
12
+}
0 commit comments