pool

package
v0.0.0-...-237f4c2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: GPL-3.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const (
	WAIT_FOR_TIMEOUT      time.Duration = 10 * time.Second
	THREAED_UP_GRACE_TIME time.Duration = 3 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Runnable

type Runnable interface {
	// Executes Runnable code
	Run() error
	// Gracefully stops Runnable code
	Stop() error
	// Forces to interrupt the thread
	Kill() error
	// Pause the execution if suits code purposes
	Pause() error
	// Resume the execution if suits code purposes
	Resume() error
	// Verify if component is running if suits code purposes
	IsRunning() bool
	// Verify if component is pause
	IsPaused() bool
	// Verify if code execution is consumed successfulyy or not
	IsComplete() bool
	// Retrieve unique Id of the component instance
	UUID() string
	// Returns the code execution duration until the request
	UpTime() time.Duration
}

Defines a single running unit of operational code

type ThreadErrorHandler

type ThreadErrorHandler interface {
	HandleError(uuid string, e error)
}

type ThreadPool

type ThreadPool interface {
	// Add new Runnable component in the ThreadPool
	Schedule(r Runnable) error
	// Start execution of ThreadPool
	Start() error
	// Stop gracefully execution of ThreadPool
	Stop() error
	// Pause temporarly execution of ThreadPool
	Pause() error
	// Resume paused execution of ThreadPool
	Resume() error
	//Reset state if ThreadPool is stopped and complete
	Reset() error
	// Verify is ThreadPool is running
	IsStarted() bool
	// Verify if all allocated threads are complete
	IsComplete() bool
	// Verify if ThreadPool is paused
	IsPaused() bool
	// Stop main thread waiting for ThreadPool completion
	WaitFor() error
	// Set Runnable errors listener, used to report errors occured
	// during ThreadPool operational time, executing scheduled
	// Runnable code
	SetErrorHandler(h ThreadErrorHandler)
	// Prints state of running processes and number of elements in the Queue
	State() string
	// Sets the logger
	SetLogger(l log.Logger)
}

Defined Operational interface of a Thread Pool Manager

func NewThreadPool

func NewThreadPool(maxThreads int64, parallel bool) ThreadPool

Jump to

Keyboard shortcuts

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