Source File
ptr.go
Belonging Package
src.elv.sh/pkg/eval/vars
package varsimport ()type PtrVar struct {ptr interface{}mutex *sync.RWMutex}// FromPtrWithMutex creates a variable from a pointer. The variable is kept in// sync with the value the pointer points to, converting with vals.ScanToGo and// vals.FromGo when Get and Set. Its access is guarded by the supplied mutex.func ( interface{}, *sync.RWMutex) PtrVar {return PtrVar{, }}// FromPtr creates a variable from a pointer. The variable is kept in sync with// the value the pointer points to, converting with vals.ScanToGo and// vals.FromGo when Get and Set. Its access is guarded by a new mutex.func ( interface{}) PtrVar {return FromPtrWithMutex(, new(sync.RWMutex))}// FromInit creates a variable with an initial value. The variable created// can be assigned values of any type.func ( interface{}) Var {return FromPtr(&)}// Get returns the value pointed by the pointer, after conversion using FromGo.func ( PtrVar) () interface{} {return vals.FromGo(.GetRaw())}// GetRaw returns the value pointed by the pointer without any conversion.func ( PtrVar) () interface{} {.mutex.RLock()defer .mutex.RUnlock()return reflect.Indirect(reflect.ValueOf(.ptr)).Interface()}// Set sets the value pointed by the pointer, after conversion using ScanToGo.func ( PtrVar) ( interface{}) error {.mutex.Lock()defer .mutex.Unlock()return vals.ScanToGo(, .ptr)}
The pages are generated with Golds v0.2.8-preview. (GOOS=darwin GOARCH=arm64)