xsync

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cond

type Cond struct {
	L sync.Locker
	// contains filtered or unexported fields
}

func NewCond

func NewCond(locker sync.Locker) *Cond

func (*Cond) Broadcast

func (c *Cond) Broadcast()

Broadcast notifies all goroutines that wait in Cond.

func (*Cond) Signal

func (c *Cond) Signal()

Signal notify one goroutine that wait in Cond.

func (*Cond) Wait

func (c *Cond) Wait(ctx context.Context) error

Wait like Go standard library's sync.Cond.Wait. have to lock the lock before calling Wait.

Wait will lock the lock and add the current goroutine to the wait list.

When Wait is invoked, the current goroutine will release the lock first and go to the wait list.

( waiting for other goroutines to invoke Signal or Broadcast ).

After being notified, Wait will lock the lock and return. The point of this is that can hold the lock again after the Wait method returns. It is safe to check conditions and process data.

type Map

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

Map is generic packing for sync.Map.

func (*Map[K, V]) Delete

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

func (*Map[K, V]) Load

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

func (*Map[K, V]) LoadAndDelete

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

func (*Map[K, V]) LoadOrStore

func (m *Map[K, V]) LoadOrStore(ket K, val V) (V, bool)

func (*Map[K, V]) Range

func (m *Map[K, V]) Range(fn func(key K, val V) bool)

func (*Map[K, V]) Store

func (m *Map[K, V]) Store(key K, val V)

type Pool

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

Pool is simple packing for sync.Pool.

func NewPool

func NewPool[T any](factory func() T) *Pool[T]

NewPool creates a new pool with a factory function. factory must not return nil.

func (*Pool[T]) Get

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

Get gets a new object from the pool.

func (*Pool[T]) Put

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

Put puts an object back into the pool.

Jump to

Keyboard shortcuts

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