zsync

package
v0.9.17 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter added in v0.9.1

type Counter struct {
	Value int
	// contains filtered or unexported fields
}

func NewCounter added in v0.9.1

func NewCounter() *Counter

func (*Counter) Add added in v0.9.1

func (c *Counter) Add(val int)

func (*Counter) Set added in v0.9.1

func (c *Counter) Set(val int)

func (*Counter) WaitExactly added in v0.9.1

func (c *Counter) WaitExactly(val int) <-chan bool

type LockerMap added in v0.8.1

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

A LockerMap manages a map of sync.Mutex for safely accessing resources that are distinguished by a key

func NewLockerMap added in v0.8.1

func NewLockerMap(capacity int) *LockerMap

func (*LockerMap) Lock added in v0.8.1

func (m *LockerMap) Lock(key string) sync.Locker

Lock a resource. Calls sync.Mutex.Lock() for the mutex defined for this key.

func (*LockerMap) Unlock added in v0.8.1

func (m *LockerMap) Unlock(key string)

Unlock a resource that was locked. Calls sync.Mutex.Unlock() for the mutex defined for this key.

func (*LockerMap) With added in v0.8.1

func (m *LockerMap) With(key string, cb func())

Safely read/write a resource using a function

type MaxLimiter

type MaxLimiter struct {
	Active  int
	Pending int
	Max     int
	// contains filtered or unexported fields
}

func NewMaxLimiter

func NewMaxLimiter(max int) *MaxLimiter

Keep number of active locks below the Max count. Useful for limiting the number of goroutines running simultaneously

func (*MaxLimiter) Lock

func (l *MaxLimiter) Lock()

Lock will wait until Active < Max

func (*MaxLimiter) Unlock

func (l *MaxLimiter) Unlock()

Must call unlock when work is completed

type RWLockerMap added in v0.8.1

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

Create a map of sync.RWMutex

func NewRWLockerMap added in v0.8.1

func NewRWLockerMap(capacity int) *RWLockerMap

func (*RWLockerMap) Lock added in v0.8.1

func (m *RWLockerMap) Lock(key string) *sync.RWMutex

Lock a resource for reading. Calls sync.RWMutex.Lock on the mutex for this key.

func (*RWLockerMap) RLock added in v0.8.1

func (m *RWLockerMap) RLock(key string) *sync.RWMutex

Lock a resource for reading. Calls sync.RWMutex.RLock on the mutex for this key.

func (*RWLockerMap) RUnlock added in v0.8.1

func (m *RWLockerMap) RUnlock(key string)

Unlock a resource that was locked for reading. Calls sync.RWMutex.Unlock on the mutex for this key.

func (*RWLockerMap) RWith added in v0.8.1

func (m *RWLockerMap) RWith(key string, cb func())

Safely read from a resource using a function

func (*RWLockerMap) Unlock added in v0.8.1

func (m *RWLockerMap) Unlock(key string)

Unlock a resource that was locked for reading a writing. Calls sync.RWMutex.Unlock on the mutex for this key.

func (*RWLockerMap) With added in v0.8.1

func (m *RWLockerMap) With(key string, cb func())

Safely read/write a resource using a function

Jump to

Keyboard shortcuts

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