Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Datum ¶
type Datum struct {
// contains filtered or unexported fields
}
Datum is used as the main return type, producing namespaced mutexes on demand.
func New ¶
New creates a new Datum based on the given options; default options will be used, if necessary.
func NewDefault ¶
func NewDefault() *Datum
NewDefault is equivalent to the New constructor function with default options.
func (*Datum) GetLocked ¶
func (d *Datum) GetLocked( isReadOnly bool, namespaces ...string, ) (mutex *MutexWrapper)
GetLocked returns a locked mutex based on the given namespaces. The mutex must be unlocked after use, and its lock will be either read-only or read-write.
func (*Datum) GetLockedIfUnique ¶ added in v1.3.1
func (d *Datum) GetLockedIfUnique( isReadOnly bool, namespaces []string, excludedNamespaces [][]string, ) (mutex *MutexWrapper, found bool)
GetLockedIfUnique attempts to return a locked mutex based on the given namespaces. However, if any collection of namespaces from the list of excluded namespaces produces the same mutex, then no mutex will be returned or locked. If a mutex is found, it must be unlocked after use, and its lock will be either read-only or read-write.
type MutexWrapper ¶
type MutexWrapper struct {
// contains filtered or unexported fields
}
MutexWrapper is returned from the GetLocked function; it is a wrapper around a read-write mutex.
func (*MutexWrapper) Raw ¶
func (m *MutexWrapper) Raw() *sync.RWMutex
Raw returns the underlying RWMutex pointer. There should ordinarily be no need to call this function.
func (*MutexWrapper) Unlock ¶
func (m *MutexWrapper) Unlock()
Unlock must be called when the mutex is no longer in use. It can be called multiple times without triggering a panic, but it should ideally only be called once after every use.