scheduler

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	WorkerCount int
}

func NewOptions

func NewOptions() *Options

type Scheduler

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

func NewScheduler

func NewScheduler(options *Options) *Scheduler

func (*Scheduler) AddTask

func (scheduler *Scheduler) AddTask(taskID uint64, privData interface{}, fn func(*Task, interface{}) TaskState) *Task

func (*Scheduler) DeleteTask

func (scheduler *Scheduler) DeleteTask(taskID uint64)

func (*Scheduler) GetAllTasks

func (scheduler *Scheduler) GetAllTasks() []*Task

func (*Scheduler) GetState

func (scheduler *Scheduler) GetState() SchedulerState

func (*Scheduler) GetTask

func (scheduler *Scheduler) GetTask(taskID uint64) *Task

func (*Scheduler) Start

func (scheduler *Scheduler) Start()

func (*Scheduler) Stop

func (scheduler *Scheduler) Stop()

func (*Scheduler) Trigger

func (scheduler *Scheduler) Trigger(signal SignalType)

type SchedulerState

type SchedulerState int32
const (
	STATE_IDLE SchedulerState = iota
	STATE_AWAKE
)

type SignalType

type SignalType int32
const (
	SIGNAL_AWAKE SignalType = iota
)

type Task

type Task struct {
	ID       uint64
	State    TaskState
	PrivData interface{}
	Handler  func(*Task, interface{}) TaskState
	// contains filtered or unexported fields
}

func NewTask

func NewTask(id uint64, privData interface{}, fn func(*Task, interface{}) TaskState) *Task

func (*Task) Execute

func (task *Task) Execute()

func (*Task) GetState

func (task *Task) GetState() TaskState

func (*Task) SetState

func (task *Task) SetState(state TaskState)

type TaskState

type TaskState int32
const (
	TASK_STATE_IDLE TaskState = iota
	TASK_STATE_PREPARED
	TASK_STATE_RUNNING
)

Jump to

Keyboard shortcuts

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