package xsync

import "github.com/ydb-platform/ydb-go-sdk/v3/internal/xsync"

Index

Functions

func NewLastUsage

func NewLastUsage(opts ...lastUsageOption) *lastUsage

func OnceFunc

func OnceFunc(f func(ctx context.Context) error) func(ctx context.Context) error

func WithClock

func WithClock(clock clockwork.Clock) lastUsageOption

func WithLock

func WithLock[T any](l mutex, f func() T) T

func WithRLock

func WithRLock[T any](l rwMutex, f func() T) T

Types

type EventBroadcast

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

func (b *EventBroadcast) Broadcast()

func (*EventBroadcast) Waiter

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 LastUsage

type LastUsage interface {
	Get() time.Time
	Start() (stop func())
}

type Map

type Map[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func (*Map[K, V]) Clear

func (m *Map[K, V]) Clear() (removed int)

func (*Map[K, V]) Delete

func (m *Map[K, V]) Delete(key K) bool

func (*Map[K, V]) Extract

func (m *Map[K, V]) Extract(key K) (value V, ok bool)

func (*Map[K, V]) Get

func (m *Map[K, V]) Get(key K) (value V, ok bool)

func (*Map[K, V]) Has

func (m *Map[K, V]) Has(key K) bool

func (*Map[K, V]) Must

func (m *Map[K, V]) Must(key K) (value V)

func (*Map[K, V]) Range

func (m *Map[K, V]) Range(f func(key K, value V) bool)

func (*Map[K, V]) Set

func (m *Map[K, V]) Set(key K, value V)

func (*Map[K, V]) Size

func (m *Map[K, V]) Size() int

type Mutex

type Mutex struct {
	sync.Mutex
}

func (*Mutex) WithLock

func (l *Mutex) WithLock(f func())

type Once

type Once[T closer.Closer] struct {
	// contains filtered or unexported fields
}

func OnceValue

func OnceValue[T closer.Closer](f func() (T, error)) *Once[T]

func (*Once[T]) Close

func (v *Once[T]) Close(ctx context.Context) (err error)

func (*Once[T]) Get

func (v *Once[T]) Get() (T, error)

func (*Once[T]) Must

func (v *Once[T]) Must() T

type OneTimeWaiter

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

func (*OneTimeWaiter) Done

func (w *OneTimeWaiter) Done() <-chan struct{}

type Pool

type Pool[T any] struct {
	New func() *T
	// contains filtered or unexported fields
}

func (*Pool[T]) GetOrNew

func (p *Pool[T]) GetOrNew() *T

func (*Pool[T]) GetOrNil

func (p *Pool[T]) GetOrNil() *T

func (*Pool[T]) Put

func (p *Pool[T]) Put(t *T)

type RWMutex

type RWMutex struct {
	sync.RWMutex
}

func (*RWMutex) WithLock

func (l *RWMutex) WithLock(f func())

func (*RWMutex) WithRLock

func (l *RWMutex) WithRLock(f func())

type Set

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

func (*Set[T]) Add

func (s *Set[T]) Add(key T) bool

func (*Set[T]) Clear

func (s *Set[T]) Clear() (removed int)

func (*Set[T]) Has

func (s *Set[T]) Has(key T) bool

func (*Set[T]) Range

func (s *Set[T]) Range(f func(key T) bool)

func (*Set[T]) Remove

func (s *Set[T]) Remove(key T) bool

func (*Set[T]) Size

func (s *Set[T]) Size() int

func (*Set[T]) Values

func (s *Set[T]) Values() []T

type Value

type Value[T any] struct {
	// contains filtered or unexported fields
}

func NewValue

func NewValue[T any](initValue T) *Value[T]

func (*Value[T]) Change

func (v *Value[T]) Change(change func(old T) T)

func (*Value[T]) Get

func (v *Value[T]) Get() T

Source Files

event_broadcast.go last_usage_guard.go last_usage_guard_start.go map.go mutex.go once.go pool.go set.go value.go

Version
v3.77.0
Published
Aug 22, 2024
Platform
linux/amd64
Imports
8 packages
Last checked
33 seconds ago

Tools for package owners.