Documentation
¶
Index ¶
- func NewLastUsage(opts ...lastUsageOption) *lastUsage
- func OnceFunc(f func(ctx context.Context) error) func(ctx context.Context) error
- func WithClock(clock clockwork.Clock) lastUsageOption
- func WithLock[T any](l mutex, f func() T) T
- func WithRLock[T any](l rwMutex, f func() T) T
- type EventBroadcast
- type LastUsage
- type Map
- func (m *Map[K, V]) Clear() (removed int)
- func (m *Map[K, V]) Delete(key K) bool
- func (m *Map[K, V]) Extract(key K) (value V, ok bool)
- func (m *Map[K, V]) Get(key K) (value V, ok bool)
- func (m *Map[K, V]) Has(key K) bool
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) Must(key K) (value V)
- func (m *Map[K, V]) Range(f func(key K, value V) bool)
- func (m *Map[K, V]) Set(key K, value V)
- type Mutex
- type Once
- type OneTimeWaiter
- type Pool
- type RWMutex
- type Set
- type SoftWeightedSemaphore
- type UnboundedChan
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLastUsage ¶ added in v3.65.0
func NewLastUsage(opts ...lastUsageOption) *lastUsage
Types ¶
type EventBroadcast ¶ added in v3.38.0
type EventBroadcast struct {
// contains filtered or unexported fields
}
EventBroadcast is implementation of broadcast notify about event Zero value is usable, must not copy after first call any method
func (*EventBroadcast) Broadcast ¶ added in v3.38.0
func (b *EventBroadcast) Broadcast()
func (*EventBroadcast) Waiter ¶ added in v3.38.0
func (b *EventBroadcast) Waiter() OneTimeWaiter
Waiter return channel, that will close when next event will be broadcast. For prevent race between subscribe and event client code must subscribe at first, then check condition if false - wait closing channed and check condition again
type Map ¶ added in v3.75.1
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
type OneTimeWaiter ¶ added in v3.38.0
type OneTimeWaiter struct {
// contains filtered or unexported fields
}
func (*OneTimeWaiter) Done ¶ added in v3.38.0
func (w *OneTimeWaiter) Done() <-chan struct{}
type Pool ¶ added in v3.75.0
type Pool[T any] struct { New func() *T // contains filtered or unexported fields }
type Set ¶ added in v3.76.0
type Set[T comparable] struct { // contains filtered or unexported fields }
type SoftWeightedSemaphore ¶ added in v3.106.0
type SoftWeightedSemaphore struct {
// contains filtered or unexported fields
}
SoftWeightedSemaphore extends semaphore.Weighted with ability to acquire one request over capacity if semaphore is completely free
func NewSoftWeightedSemaphore ¶ added in v3.106.0
func NewSoftWeightedSemaphore(n int64) *SoftWeightedSemaphore
NewSoftWeightedSemaphore creates new SoftWeightedSemaphore with given capacity
func (*SoftWeightedSemaphore) Acquire ¶ added in v3.106.0
func (s *SoftWeightedSemaphore) Acquire(ctx context.Context, n int64) error
Acquire acquires the semaphore with a weight of n. If the semaphore is completely free, the acquisition will succeed regardless of weight.
func (*SoftWeightedSemaphore) Release ¶ added in v3.106.0
func (s *SoftWeightedSemaphore) Release(n int64)
Release releases n tokens back to the semaphore.
func (*SoftWeightedSemaphore) TryAcquire ¶ added in v3.106.0
func (s *SoftWeightedSemaphore) TryAcquire(n int64) bool
TryAcquire tries to acquire the semaphore with a weight of n without blocking. If the semaphore is completely free, the acquisition will succeed regardless of weight.
type UnboundedChan ¶ added in v3.110.0
type UnboundedChan[T any] struct { // contains filtered or unexported fields }
UnboundedChan is a generic unbounded channel implementation that supports message merging and concurrent access.
func NewUnboundedChan ¶ added in v3.110.0
func NewUnboundedChan[T any]() *UnboundedChan[T]
NewUnboundedChan creates a new UnboundedChan instance.
func (*UnboundedChan[T]) Close ¶ added in v3.110.0
func (c *UnboundedChan[T]) Close()
Close closes the channel. After closing, Send and SendWithMerge operations will be ignored, and Receive will return (zero_value, false) once the buffer is empty.
func (*UnboundedChan[T]) Receive ¶ added in v3.110.0
func (c *UnboundedChan[T]) Receive(ctx context.Context) (T, bool, error)
Receive retrieves a message from the channel with context support. Returns (message, true, nil) if a message is available. Returns (zero_value, false, nil) if the channel is closed and empty. Returns (zero_value, false, context.Canceled) if context is cancelled. Returns (zero_value, false, context.DeadlineExceeded) if context times out.
func (*UnboundedChan[T]) Send ¶ added in v3.110.0
func (c *UnboundedChan[T]) Send(msg T)
Send adds a message to the channel. The operation is non-blocking and thread-safe.
func (*UnboundedChan[T]) SendWithMerge ¶ added in v3.110.0
func (c *UnboundedChan[T]) SendWithMerge(msg T, mergeFunc func(last, new T) (T, bool))
SendWithMerge adds a message to the channel with optional merging. If mergeFunc returns true, the new message will be merged with the last message. The merge operation is atomic and preserves message order.