sync

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrentMap

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

ConcurrentMap is a thread-safe Map implementation.

func NewConcurrentMap

func NewConcurrentMap() *ConcurrentMap

NewConcurrentMap creates a new ConcurrentMap.

func (*ConcurrentMap) Delete

func (m *ConcurrentMap) Delete(key interface{})

Delete deletes a key-value pair from the Map.

func (*ConcurrentMap) Get

func (m *ConcurrentMap) Get(key interface{}) (interface{}, bool)

Get gets a value from the Map by key.

func (*ConcurrentMap) Put

func (m *ConcurrentMap) Put(key, value interface{})

Put puts a key-value pair into the Map.

func (*ConcurrentMap) Size

func (m *ConcurrentMap) Size() int

Size returns the number of key-value pairs in the Map.

type ConcurrentQueue

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

ConcurrentQueue is a simple thread-safe queue.

func NewConcurrentQueue

func NewConcurrentQueue() *ConcurrentQueue

NewConcurrentQueue creates a new ConcurrentQueue.

func (*ConcurrentQueue) Dequeue

func (q *ConcurrentQueue) Dequeue() (interface{}, bool)

Dequeue removes an element from the beginning of the queue and returns it.

func (*ConcurrentQueue) Enqueue

func (q *ConcurrentQueue) Enqueue(item interface{})

Enqueue adds an element to the end of the queue.

func (*ConcurrentQueue) Size

func (q *ConcurrentQueue) Size() int

Size returns the number of elements in the queue.

type ConcurrentSet

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

ConcurrentSet is a thread-safe Set implementation.

func NewConcurrentSet

func NewConcurrentSet() *ConcurrentSet

NewConcurrentSet creates a new ConcurrentSet.

func (*ConcurrentSet) Add

func (s *ConcurrentSet) Add(item interface{})

Add adds an element to the Set.

func (*ConcurrentSet) Contains

func (s *ConcurrentSet) Contains(item interface{}) bool

Contains checks if an element is in the Set.

func (*ConcurrentSet) Remove

func (s *ConcurrentSet) Remove(item interface{})

Remove removes an element from the Set.

func (*ConcurrentSet) Size

func (s *ConcurrentSet) Size() int

Size returns the number of elements in the Set.

type Counter

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

Counter is a thread-safe counter.

func NewCounter

func NewCounter() *Counter

NewCounter creates a new Counter.

func (*Counter) Decrement

func (c *Counter) Decrement()

Decrement decreases the counter by 1.

func (*Counter) Increment

func (c *Counter) Increment()

Increment increases the counter by 1.

func (*Counter) Value

func (c *Counter) Value() int

Value returns the current value of the counter.

type Semaphore

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

Semaphore is a simple semaphore implementation.

func NewSemaphore

func NewSemaphore(max int) *Semaphore

NewSemaphore creates a new Semaphore.

func (*Semaphore) Acquire

func (s *Semaphore) Acquire()

Acquire acquires a semaphore.

func (*Semaphore) Release

func (s *Semaphore) Release()

Release releases a semaphore.

type WorkerPool

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

WorkerPool is a simple worker pool implementation.

func NewWorkerPool

func NewWorkerPool(workerCount int) *WorkerPool

NewWorkerPool creates a new WorkerPool.

func (*WorkerPool) Shutdown

func (p *WorkerPool) Shutdown()

Shutdown shuts down the worker pool and waits for all tasks to complete.

func (*WorkerPool) Submit

func (p *WorkerPool) Submit(task func())

Submit submits a task to the worker pool.

Jump to

Keyboard shortcuts

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