Documentation
¶
Overview ¶
Package concurrency provides utility functions for working with goroutines.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConcurrentPool ¶
type ConcurrentPool struct {
// contains filtered or unexported fields
}
ConcurrentPool implements a simple semaphore-like structure to limit the number of concurrent goroutines working together.
func NewConcurrentPool ¶
func NewConcurrentPool(capacity uint) (*ConcurrentPool, error)
NewConcurrentPool creates a new ConcurrentPool with the specified capacity. It panics if the capacity is 0.
func (*ConcurrentPool) Lock ¶
func (p *ConcurrentPool) Lock()
Lock acquires a lock from the pool, waiting if necessary until a slot becomes available. It increments the used count using the reserveSlot method.
func (*ConcurrentPool) Unlock ¶
func (p *ConcurrentPool) Unlock()
Unlock releases a lock, making a slot available for other goroutines. It decrements the used count and sends a signal on the changeChan to notify waiting goroutines.
type LockedValue ¶ added in v0.5.0
type LockedValue[T any] struct { // contains filtered or unexported fields }
func NewLockedValue ¶ added in v0.5.0
func NewLockedValue[T any](initial T) *LockedValue[T]
Click to show internal directories.
Click to hide internal directories.