Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Enabler ¶
type Enabler interface { Enable() Disable() SetEnableFuncs(enableFunc, disableFunc func()) }
An Enabler represents an object that can be enabled or disabled. It is copied here from the types package to prevent a circular dependency.
Reference: http://
func AddEnabler ¶
func AddEnabler(fnEnable, fnDisable func()) Enabler
AddEnabler implements types.Enabler by using the given Enable and Disa ble methods. If either of these is nil, then the default implementation, a Nop, is used.
This may be used to add Enabler functionality to structures that do not implement the interface natively. For example:
type MyMutex interface { sync.Locker Enabler } type myMutex struct { mu *sync.Mutex Enabler } func (m *MyMutex) fnEnable() { m.mu.Lock() defer m.mu.Unlock() m.fnLock = m.lockFunc m.fnUnlock = m.unlockFunc } func (m *MyMutex) fnDisable() { m.mu.Lock() defer m.mu.Unlock() m.fnLock = m.noLock m.fnUnlock = m.noUnlock } var MyMutex myMutex = myMutex{ mu new(sync.Mutex) lockenabler.AddEnabler(fnEnable,fnDisable) }
Click to show internal directories.
Click to hide internal directories.