locks

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Config = struct {
	DeadlockTimeout time.Duration
	StackDepth      int
}{
	DeadlockTimeout: time.Second * 10,
	StackDepth:      50,
}

Functions

This section is empty.

Types

type CountDownLatch

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

CountDownLatch is the same as sync.WaitGroup but with the ability to wait with timeout

func NewCountDownLatch

func NewCountDownLatch() *CountDownLatch

NewCountDownLatch creates a new CountDownLatch

func (*CountDownLatch) Add

func (l *CountDownLatch) Add(delta int)

Add increases/decreases the countdown

func (*CountDownLatch) Close

func (l *CountDownLatch) Close()

Close closes the latch unblocking wait

func (*CountDownLatch) Counter

func (l *CountDownLatch) Counter() int

Counter returns the current count down number

func (*CountDownLatch) Done

func (l *CountDownLatch) Done()

Done decreases the countdown by one

func (*CountDownLatch) Wait

func (l *CountDownLatch) Wait() <-chan struct{}

Wait to be unblocked

func (*CountDownLatch) WaitWithTimeout

func (l *CountDownLatch) WaitWithTimeout(timeout time.Duration) bool

WaitWithTimeout waits until the timeout runs out or until the countdown is zero

type Latch

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

Latch reusable lock that uses a channel to wait for the release of the lock

func NewLatch

func NewLatch() *Latch

NewLatch creates a new LockerChan

func (*Latch) Lock

func (c *Latch) Lock()

Lock locks the release of wait

func (*Latch) Unlock

func (c *Latch) Unlock()

Unlock releases the lock

func (*Latch) Wait

func (c *Latch) Wait() <-chan struct{}

Wait wait for the lock to be released

type Mutex

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

func (*Mutex) Lock

func (m *Mutex) Lock()

func (*Mutex) Unlock

func (m *Mutex) Unlock()

type RWMutex

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

func (*RWMutex) Lock

func (m *RWMutex) Lock()

func (*RWMutex) RLock

func (m *RWMutex) RLock()

func (*RWMutex) RUnlock

func (m *RWMutex) RUnlock()

func (*RWMutex) Unlock

func (m *RWMutex) Unlock()

type RedisLock added in v0.0.3

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

func NewRedisLock added in v0.0.3

func NewRedisLock(redisAddresses []string, lockName string, expiry time.Duration) (RedisLock, error)

func (RedisLock) Extend added in v0.0.3

func (l RedisLock) Extend() (bool, error)

func (RedisLock) Lock added in v0.0.3

func (l RedisLock) Lock() (bool, error)

func (RedisLock) Unlock added in v0.0.3

func (l RedisLock) Unlock() (bool, error)

Jump to

Keyboard shortcuts

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