util

package
v0.50.2 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPoolClosed = ants.ErrPoolClosed

ErrPoolClosed is returned when submitting task to a closed pool.

Functions

func MkdirAllX added in v0.24.0

func MkdirAllX(path string, perm os.FileMode) error

MkdirAllX calls os.MkdirAll with the passed permissions but with +x for a user and a group. This makes the created dir openable regardless of the passed permissions.

func NewSaltingWriter added in v0.14.1

func NewSaltingWriter(w io.Writer, salt []byte) io.Writer

NewSaltingWriter returns io.Writer instance that applies salt to written data and write the result to w.

func SaltXOR

func SaltXOR(data, salt []byte) []byte

SaltXOR xors bits of data with salt repeating salt if necessary.

func SaltXOROffset added in v0.14.1

func SaltXOROffset(data, salt []byte, off int) []byte

SaltXOROffset xors bits of data with salt starting from off byte repeating salt if necessary.

func SingleAsyncExecutingInstance added in v0.50.2

func SingleAsyncExecutingInstance(f func()) (func(), func())

SingleAsyncExecutingInstance returns func that works the same as f, but calling it is non-blocking and not more than a single routine is being executed at a time. The second return value is a blocking stop function that disallows f execution after calling it. Stop function blocks until f execution is finished (if any).

Types

type WorkerPool

type WorkerPool interface {
	// Submit queues a function for execution
	// in a separate routine.
	//
	// Implementation must return any error encountered
	// that prevented the function from being queued.
	Submit(func()) error

	// Release releases worker pool resources. All `Submit` calls will
	// finish with ErrPoolClosed. It doesn't wait until all submitted
	// functions have returned so synchronization must be achieved
	// via other means (e.g. sync.WaitGroup).
	Release()

	// Tune changes the capacity of this pool.
	Tune(int)
}

WorkerPool represents a tool to control the execution of go-routine pool.

func NewPseudoWorkerPool added in v0.26.1

func NewPseudoWorkerPool() WorkerPool

NewPseudoWorkerPool returns a new instance of a synchronous worker pool.

Directories

Path Synopsis
logger
meta

Jump to

Keyboard shortcuts

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