Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Go ¶
func Go(f func())
Go start an new goroutine, and copy all local allStoreMap from current goroutine.
func InheritContext ¶
func InheritContext(ic *ImmutableContext)
InheritContext load the specified ImmutableContext instance into the local storage of current goroutine.
Types ¶
type G ¶ added in v1.0.0
type G interface { // Goid returns g.goid Goid() int64 // Labels returns g.labels, which's real type is map[string]string Labels() map[string]string // Status returns g.atomicstatus Status() GStatus }
G defines some usefull api to access the underlying go-routine.
type GStatus ¶ added in v1.0.0
type GStatus uint32
GStatus represents the real status of runtime.g
const ( GIdle GStatus = 0 // see runtime._Gidle GRunnable GStatus = 1 // see runtime._Grunnable GRunning GStatus = 2 // see runtime._Grunning GSyscall GStatus = 3 // see runtime._Gsyscall GWaiting GStatus = 4 // see runtime._Gwaiting GMoribund GStatus = 5 // see runtime._Gmoribund_unused GDead GStatus = 6 // see runtime._Gdead GEnqueue GStatus = 7 // see runtime._Genqueue_unused GCopystack GStatus = 8 // see runtime._Gcopystack GPreempted GStatus = 9 // see runtime._Gpreempted )
type ImmutableContext ¶
type ImmutableContext struct {
// contains filtered or unexported fields
}
ImmutableContext represents all local allStoreMap of one goroutine.
func BackupContext ¶
func BackupContext() *ImmutableContext
BackupContext copy all local allStoreMap into an ImmutableContext instance.
type LocalStorage ¶
type LocalStorage interface { // Get returns the value in the current goroutine's local storage, if it was set before. Get() (value interface{}) // Set copy the value into the current goroutine's local storage, and return the old value. Set(value interface{}) (oldValue interface{}) // Del delete the value from the current goroutine's local storage, and return it. Del() (oldValue interface{}) }
LocalStorage provides goroutine-local variables.
func NewLocalStorage ¶
func NewLocalStorage() LocalStorage
NewLocalStorage create and return a new LocalStorage instance.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.