gxsync

package
v1.11.15 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2021 License: Apache-2.0 Imports: 13 Imported by: 46

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PoolBusyErr = perrors.New("pool is busy")
)

Functions

This section is empty.

Types

type ConnectionPool added in v1.11.16

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

func (ConnectionPool) Close added in v1.11.16

func (p ConnectionPool) Close()

func (ConnectionPool) IsClosed added in v1.11.16

func (p ConnectionPool) IsClosed() bool

func (ConnectionPool) NumWorkers added in v1.11.16

func (p ConnectionPool) NumWorkers() int32

func (*ConnectionPool) Submit added in v1.11.16

func (p *ConnectionPool) Submit(t task) error

func (*ConnectionPool) SubmitSync added in v1.11.16

func (p *ConnectionPool) SubmitSync(t task) error

type GenericTaskPool added in v1.9.6

type GenericTaskPool interface {
	// AddTask wait idle worker add task
	AddTask(t task) bool
	// AddTaskAlways add task to queues or do it immediately
	AddTaskAlways(t task)
	// AddTaskBalance add task to idle queue
	AddTaskBalance(t task)
	// Close use to close the task pool
	Close()
	// IsClosed use to check pool status.
	IsClosed() bool
}

GenericTaskPool represents an generic task pool.

func NewTaskPool

func NewTaskPool(opts ...TaskPoolOption) GenericTaskPool

NewTaskPool build a task pool

func NewTaskPoolSimple added in v1.9.6

func NewTaskPoolSimple(size int) GenericTaskPool

NewTaskPoolSimple build a simple task pool

type TaskPool

type TaskPool struct {
	TaskPoolOptions
	// contains filtered or unexported fields
}

/////////////////////////////////////// Task Pool /////////////////////////////////////// task pool: manage task ts

func (*TaskPool) AddTask

func (p *TaskPool) AddTask(t task) (ok bool)

return false when the pool is stop

func (*TaskPool) AddTaskAlways added in v1.7.0

func (p *TaskPool) AddTaskAlways(t task)

func (*TaskPool) AddTaskBalance added in v1.7.0

func (p *TaskPool) AddTaskBalance(t task)

do it immediately when no idle queue

func (*TaskPool) Close

func (p *TaskPool) Close()

func (*TaskPool) IsClosed

func (p *TaskPool) IsClosed() bool

check whether the session has been closed.

type TaskPoolOption

type TaskPoolOption func(*TaskPoolOptions)

func WithTaskPoolTaskPoolSize

func WithTaskPoolTaskPoolSize(size int) TaskPoolOption

WithTaskPoolTaskPoolSize set @size of the task queue pool size

func WithTaskPoolTaskQueueLength

func WithTaskPoolTaskQueueLength(length int) TaskPoolOption

WithTaskPoolTaskQueueLength set @length of the task queue length

func WithTaskPoolTaskQueueNumber

func WithTaskPoolTaskQueueNumber(number int) TaskPoolOption

WithTaskPoolTaskQueueNumber set @number of the task queue number

type TaskPoolOptions

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

TaskPoolOptions is optional settings for task pool

type WorkerPool added in v1.11.16

type WorkerPool interface {
	// Submit adds a task to queue asynchronously.
	Submit(task) error
	// SubmitSync adds a task to queue synchronously.
	SubmitSync(task) error
	// Close closes the worker pool
	Close()
	// IsClosed returns close status of the worker pool
	IsClosed() bool
	// NumWorkers returns the number of workers
	NumWorkers() int32
}

func NewConnectionPool added in v1.11.16

func NewConnectionPool(config WorkerPoolConfig) WorkerPool

type WorkerPoolConfig added in v1.11.16

type WorkerPoolConfig struct {
	NumWorkers int
	NumQueues  int
	QueueSize  int
	Logger     gxlog.Logger
}

Jump to

Keyboard shortcuts

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