task

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 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      *Executor = 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) 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 struct {
	// contains filtered or unexported fields
}

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 (*Task) AddRefCnt

func (t *Task) AddRefCnt(cnt int32) int32

func (*Task) BroadcastToAllExecutor

func (t *Task) BroadcastToAllExecutor() bool

func (*Task) Get

func (t *Task) Get() interface{}

func (*Task) GetCostTime

func (t *Task) GetCostTime() time.Duration

func (*Task) GetEnv

func (t *Task) GetEnv(k interface{}) interface{}

func (*Task) GetRefCnt

func (t *Task) GetRefCnt() int32

func (*Task) GetRunTime

func (t *Task) GetRunTime() time.Duration

func (*Task) GetWithTimeout

func (t *Task) GetWithTimeout(timeout time.Duration) interface{}

func (*Task) PutEnv

func (t *Task) PutEnv(k, v interface{}) bool

func (*Task) SetAlertTime

func (t *Task) SetAlertTime(alertt time.Duration)

func (*Task) Start

func (t *Task) Start()

func (*Task) StartByExecutor

func (t *Task) StartByExecutor(name string) bool

func (*Task) StartByFixExecutor

func (t *Task) StartByFixExecutor(name string) bool

func (*Task) StartByGroupExecutor

func (t *Task) StartByGroupExecutor(gname string, name string) bool

func (*Task) StartByGroupFixExecutor

func (t *Task) StartByGroupFixExecutor(name, gname string) 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