lsync

package
v0.0.0-...-1ed3a2a Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LRWMutex

type LRWMutex struct {
	// contains filtered or unexported fields
}

A LRWMutex is a mutual exclusion lock with timeouts.

func NewLRWMutex

func NewLRWMutex() *LRWMutex

NewLRWMutex - initializes a new lsync RW mutex.

func (*LRWMutex) DRLocker

func (lm *LRWMutex) DRLocker() sync.Locker

DRLocker returns a sync.Locker interface that implements the Lock and Unlock methods by calling drw.RLock and drw.RUnlock.

func (*LRWMutex) ForceUnlock

func (lm *LRWMutex) ForceUnlock()

ForceUnlock will forcefully clear a write or read lock.

func (*LRWMutex) GetLock

func (lm *LRWMutex) GetLock(ctx context.Context, id string, source string, timeout time.Duration) (locked bool)

GetLock tries to get a write lock on lm before the timeout occurs.

func (*LRWMutex) GetRLock

func (lm *LRWMutex) GetRLock(ctx context.Context, id string, source string, timeout time.Duration) (locked bool)

GetRLock tries to get a read lock on lm before the timeout occurs.

func (*LRWMutex) Lock

func (lm *LRWMutex) Lock()

Lock holds a write lock on lm.

If the lock is already in use, the calling go routine blocks until the mutex is available.

func (*LRWMutex) RLock

func (lm *LRWMutex) RLock()

RLock holds a read lock on lm.

If one or more read lock are already in use, it will grant another lock. Otherwise the calling go routine blocks until the mutex is available.

func (*LRWMutex) RUnlock

func (lm *LRWMutex) RUnlock()

RUnlock releases a read lock held on lm.

It is a run-time error if lm is not locked on entry to RUnlock.

func (*LRWMutex) Unlock

func (lm *LRWMutex) Unlock()

Unlock unlocks the write lock.

It is a run-time error if lm is not locked on entry to Unlock.

Jump to

Keyboard shortcuts

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