Documentation ¶
Overview ¶
Description: This file contains the implementation of a simple semaphore. It is used to control the number of resources that can be accessed concurrently.
Description: This package provides a worker pool implementation for concurrency limiting. It includes a Pool interface and a Pool struct that implements the interface.
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 ¶
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.