evthub

package
v1.2.24041 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EvtFunc

type EvtFunc func(args ...interface{}) (ok bool)

type EvtHub

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

事件中心 负责管理事件节点对象 使用方式1: A对象: 创建EvtNode, 执行事件, 释放EvtNode, (B/C/D)对象: 绑定事件 -> 解绑事件 使用方式2: (A/B/C/D): CheckGetEvtNode('001', true)获取节点, (node.绑定事件 -> node.解绑事件) / (执行事件) -> 释放EvtNode, 使用方式3: (A/B/C/D): CheckGetEvtNode('001', true), AddEvt(绑定事件) ,... , DelEvt, ReleaseEvtNode

var (
	DefaultEvtHub *EvtHub
)

func NewEvtHub

func NewEvtHub() *EvtHub

func (*EvtHub) AddEvent

func (this *EvtHub) AddEvent(nodeid string, evt EvtFunc) (evtid int32)

添加事件, 事件节点引用计数+1

func (*EvtHub) CheckGetEvtNode

func (this *EvtHub) CheckGetEvtNode(id string, newflag bool) (node *EvtNode)

func (*EvtHub) CreateEvtNode

func (this *EvtHub) CreateEvtNode(id string) (*EvtNode, error)

func (*EvtHub) DelEvent

func (this *EvtHub) DelEvent(nodeid string, evtid int32) (changed bool)

删除事件, 事件节点引用计数-1

func (*EvtHub) ReleasesEvtNode

func (this *EvtHub) ReleasesEvtNode(id string) bool

type EvtNode

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

事件节点

func (*EvtNode) Add2Evt

func (this *EvtNode) Add2Evt(fn EvtFunc) (evtid int32)

func (*EvtNode) Execute

func (this *EvtNode) Execute(max int, args ...interface{}) (cnt int)

func (*EvtNode) GetId added in v1.2.24013

func (this *EvtNode) GetId() string

func (*EvtNode) RemoveEvt

func (this *EvtNode) RemoveEvt(evtid int32) (changed bool)

Jump to

Keyboard shortcuts

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