coroutine

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coroutine

type Coroutine struct {
	ID          string
	Name        string
	Ctx         context.Context
	Cancel      context.CancelFunc
	StartedAt   time.Time
	CompletedAt time.Time
	State       CoroutineState
	Priority    int
	Error       error
	Result      lua.LValue
}

Coroutine 协程结构体

type CoroutineManager

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

CoroutineManager 协程管理器

type CoroutineModule

type CoroutineModule struct{}

CoroutineModule 协程模块

func (*CoroutineModule) IsAvailable

func (m *CoroutineModule) IsAvailable() bool

IsAvailable 检查模块是否可用

func (*CoroutineModule) Name

func (m *CoroutineModule) Name() string

Name 返回模块名称

func (*CoroutineModule) Register

func (m *CoroutineModule) Register(engine model.Engine) error

Register 向引擎注册方法

type CoroutinePool

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

CoroutinePool 协程池

func NewCoroutinePool

func NewCoroutinePool(name string, maxWorkers, maxTasks int) *CoroutinePool

NewCoroutinePool 创建协程池

func (*CoroutinePool) Close

func (p *CoroutinePool) Close()

Close 关闭协程池

func (*CoroutinePool) GetStats

func (p *CoroutinePool) GetStats() map[string]interface{}

GetStats 获取协程池统计信息

func (*CoroutinePool) Submit

func (p *CoroutinePool) Submit(task *Task) bool

Submit 提交任务到协程池

type CoroutineState

type CoroutineState int

CoroutineState 协程状态

const (
	StatePending   CoroutineState = iota // 等待中
	StateRunning                         // 运行中
	StateCompleted                       // 已完成
	StateCancelled                       // 已取消
	StateError                           // 错误
)

func (CoroutineState) String

func (s CoroutineState) String() string

String 返回状态的字符串表示

type Scheduler

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

Scheduler 调度器

func (*Scheduler) GetPriority

func (s *Scheduler) GetPriority(name string) int

GetPriority 获取优先级

func (*Scheduler) GetStrategy

func (s *Scheduler) GetStrategy() string

GetStrategy 获取调度策略

func (*Scheduler) SetPriority

func (s *Scheduler) SetPriority(name string, priority int)

SetPriority 设置优先级

func (*Scheduler) SetStrategy

func (s *Scheduler) SetStrategy(strategy string)

SetStrategy 设置调度策略

type Task

type Task struct {
	ID        string
	Function  *lua.LFunction
	Args      []lua.LValue
	Priority  int
	CreatedAt time.Time
	Ctx       context.Context
	Cancel    context.CancelFunc
}

Task 任务结构体

type Worker

type Worker struct {
	ID      int
	Pool    *CoroutinePool
	Active  bool
	Current *Task
}

Worker 工作协程

Jump to

Keyboard shortcuts

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