events

package
v0.0.0-...-7206171 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MulanPSL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PublishEvent

func PublishEvent(event *Event)

func StartEvents

func StartEvents(cap int)

func StopEvents

func StopEvents()

Types

type Event

type Event struct {
	Name  EventName   // 事件名
	Value interface{} // 事件值
}

Event 事件结构体

func NewEvent

func NewEvent(name EventName, value interface{}) *Event

NewEvent 创建一个新事件

type EventListener

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

EventListener 事件监听器结构体

func RegisterEventListener

func RegisterEventListener(name EventName, f func(workId int, value interface{})) *EventListener

RegisterEventListener 注册一个事件监听器

func (*EventListener) Execute

func (t *EventListener) Execute(workId int, value interface{})

Execute 执行事件监听器的方法

type EventName

type EventName string
const (
	EventNone EventName = "none" // 未知
)

type EventPool

type EventPool struct {
	EntryChannel chan *Event // 对外接收Task的入口

	JobsChannel chan *Event //协程池内部的任务就绪队列
	// contains filtered or unexported fields
}

EventPool 定义池类型

func (*EventPool) Run

func (p *EventPool) Run()

Run 让协程池Pool开始工作

func (*EventPool) Stop

func (p *EventPool) Stop()

Stop 让协程池Pool结束工作

Jump to

Keyboard shortcuts

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