task

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TaskErr_CannotFindWorker  = errors.New("Cannot find fit worker.")
	TaskErr_TaskExecuteObject = errors.New("Task can only be executed executor")
)
View Source
var (
	WorkerIdGenerator int32 = 0
	WorkerInitialCnt        = 8
	WorkerVirtualNum        = 8
	TaskExecutor            = NewExecutor()
)
View Source
var Config = Configuration{}
View Source
var ErrTaskIsRunning = errors.New("mutex task is running")

Functions

func SendTaskExe

func SendTaskExe(o *basic.Object, t Task) bool

func SendTaskRes

func SendTaskRes(o *basic.Object, t Task, n CompleteNotify) bool

Types

type Callable

type Callable interface {
	Call(*basic.Object) interface{}
}

type CallableWrapper

type CallableWrapper func(o *basic.Object) interface{}

func (CallableWrapper) Call

func (cw CallableWrapper) Call(o *basic.Object) interface{}

type CompleteNotify

type CompleteNotify interface {
	Done(interface{}, Task)
}

type CompleteNotifyWrapper

type CompleteNotifyWrapper func(interface{}, Task)

func (CompleteNotifyWrapper) Done

func (cnw CompleteNotifyWrapper) Done(i interface{}, t Task)

type Configuration

type Configuration struct {
	Options basic.Options
	Worker  WorkerConfig
}

func (*Configuration) Close

func (c *Configuration) Close() error

func (*Configuration) Init

func (c *Configuration) Init() error

func (*Configuration) Name

func (c *Configuration) Name() string

type Executor

type Executor struct {
	*basic.Object
	// contains filtered or unexported fields
}

func NewExecutor

func NewExecutor() *Executor

func (*Executor) AddGroup

func (e *Executor) AddGroup(gname string) *WorkerGroup

func (*Executor) Start

func (e *Executor) Start()

type Task

type Task interface {
	AddRefCnt(cnt int32) int32
	GetRefCnt() int32
	Get() interface{}
	GetWithTimeout(timeout time.Duration) interface{}
	GetEnv(k interface{}) interface{}
	PutEnv(k, v interface{}) bool
	SetAlertTime(alertt time.Duration)
	GetCostTime() time.Duration
	GetRunTime() time.Duration
	Start()
	StartByExecutor(name string) bool
	StartByFixExecutor(name string) bool
	BroadcastToAllExecutor() bool
	StartByGroupExecutor(gname string, name string) bool
	StartByGroupFixExecutor(name, gname string) bool
	// contains filtered or unexported methods
}

func New

func New(s *basic.Object, c Callable, n CompleteNotify, name ...string) Task

func NewMutexTask

func NewMutexTask(s *basic.Object, c Callable, n CompleteNotify, key, name string) (t Task, done bool)

func RunShareTask

func RunShareTask(s *basic.Object, c Callable, n CompleteNotify, key, name string) (t Task, done bool)

type Worker

type Worker struct {
	*basic.Object
}

type WorkerConfig

type WorkerConfig struct {
	Options   basic.Options
	WorkerCnt int
}

type WorkerGroup

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

Jump to

Keyboard shortcuts

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