sche

package
v0.0.0-...-799f385 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 8 Imported by: 5

Documentation

Index

Constants

View Source
const (
	ScheQueueSize = 9999
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CBFunc

type CBFunc func() (interface{}, error)

最简单的匿名函数

type FuncSelector

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

func NewFuncSelector

func NewFuncSelector(chanWait reflect.Value, fun SelectorFunc) *FuncSelector

func (*FuncSelector) DoTask

func (s *FuncSelector) DoTask(c ISelectorContainor, v reflect.Value, recvOk bool)

func (*FuncSelector) GetChannel

func (s *FuncSelector) GetChannel() reflect.Value

type IChanSelector

type IChanSelector interface {
	GetChannel() reflect.Value
	DoTask(c ISelectorContainor, v reflect.Value, recvOk bool)
}

type ISche

type ISche interface {
	AddTask(cb CBFunc) *RunTask
	Wait()
}

type ISelectorContainor

type ISelectorContainor interface {
	Dummy()
}

type MultiSelector

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

动态的加入通道读取Select 避免写一个很明确的select列表

func NewMultiSelector

func NewMultiSelector() *MultiSelector

新添加的逻辑,但是前面的通道是空的 那么需要等待前面事件 考虑加入要给超时

func (*MultiSelector) AddSelector

func (s *MultiSelector) AddSelector(selector IChanSelector)

加入一个锁

func (*MultiSelector) Dummy

func (s *MultiSelector) Dummy()

func (*MultiSelector) HandleLoop

func (s *MultiSelector) HandleLoop()

for test

func (*MultiSelector) HandleOnce

func (s *MultiSelector) HandleOnce()

func (*MultiSelector) Stop

func (s *MultiSelector) Stop()

type RunTask

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

func (*RunTask) Done

func (s *RunTask) Done(r interface{}, e error)

func (*RunTask) WaitDone

func (s *RunTask) WaitDone() (interface{}, error)

防止死锁

type RunTaskIdService

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

--------------------------

func (*RunTaskIdService) AllocId

func (s *RunTaskIdService) AllocId() uint32

type Sche

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

func NewSche

func NewSche() *Sche

func (*Sche) DoTask

func (s *Sche) DoTask(t *RunTask)

func (*Sche) GetChanTask

func (s *Sche) GetChanTask() <-chan *RunTask

集成在其他流程中

select {
case t := <- sche.GetChanTask():
	sche.DoTask(t)
}

func (*Sche) Handler

func (s *Sche) Handler()

便于测试,自己go sche.Handler

func (*Sche) Post

func (s *Sche) Post(cb CBFunc) *RunTask

TODO: 如果投递到本routine然后又WaitDone,会死锁 如何解决?或者警告 安全考虑,如果某个

func (*Sche) Stop

func (s *Sche) Stop()

type ScheMgr

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

-------------------------- 管理器,通过名字来创建和访问sche

var (
	TheScheMgr     *ScheMgr = NewScheMgr()
	DefaultScheMgr *ScheMgr = TheScheMgr
)

func NewScheMgr

func NewScheMgr() *ScheMgr

func (*ScheMgr) DelSche

func (s *ScheMgr) DelSche(name string)

func (*ScheMgr) GetSche

func (s *ScheMgr) GetSche(name string) *Sche

createIfMiss

type SelectorData

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

-----------------------------

type SelectorFunc

type SelectorFunc func(v reflect.Value, recvOk bool)

----------------------------- 函数选择器

Jump to

Keyboard shortcuts

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