Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/runtime/cockroach.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package runtime

// CurrentP returns the index of the current P, between 0 and the current
// GOMAXPROCS.
//
// This can only be used as a best-effort facility; there is no guarantee that
// the goroutine still runs on the same P when this function returns.
func CurrentP() int {
// Note: preemption is not possible in-between these loads (there are no
// preemption-safe points).
return int(getg().m.p.ptr().id)
}