workerjuice

package
v1.10.3 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: MIT Imports: 1 Imported by: 1

Documentation

Overview

Package workerjuice provides a simple semaphore implementation.

Package workerjuice provides a pool of workers for concurrent task execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool interface {
	AddWorker()
	RemoveWorker()
	WorkerCount() int
	Wait()
	Close()
}

Create an interface for the Pool struct.

func CreateEmptyPool

func CreateEmptyPool(maxWorkers uint) Pool

CreateEmptyPool creates a new worker pool with the specified maximum number of workers.

It returns a pointer to the created Pool.

type SemaphoreInterface

type SemaphoreInterface interface {
	// Acquire acquires a resource controlled by the semaphore.
	Acquire()
	// Release releases a resource controlled by the semaphore.
	Release()
	// Wait blocks until all resources have been released.
	Wait()
}

SemaphoreInterface defines the methods that a semaphore should implement.

func NewSemaphore

func NewSemaphore(concurrency int) SemaphoreInterface

NewSemaphore creates a new Semaphore with the specified concurrency level.

type Worker

type Worker struct{}

Worker represents a worker in a worker pool.

Jump to

Keyboard shortcuts

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