runtimex

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2024 License: Apache-2.0 Imports: 4 Imported by: 2

README

runtimex

Runtimex package help to expose Go Runtime internals representation safely.

Usage

Get Goroutine ID
gid, err := runtimex.GID()
Get Processor ID
pid, err := runtimex.PID()

Note

Since we use a hack way to expose internal representation of the Go runtime, so if Go change some internal variable names, the package will return error.

You should care about the error returned by runtimex and do the fallback logic If necessary.

For now, we only depend on runtime.g and g.goid.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotSupported = fmt.Errorf("%s is not supported", runtime.Version())
)

Functions

func GID

func GID() (int, error)

GID return current goroutine's ID

func PID

func PID() (int, error)

PID return current processor's ID It may not 100% accurate because the scheduler may preempt current goroutine and re-schedule it to another P after the function call return, so the caller should tolerate the preemption.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL