basic

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueueType_List int = iota
	QueueType_Chan
)
View Source
const (
	DefaultQueueBacklog int = 4
)
View Source
const OLS_INVALID_SLOT = math.MaxUint32
View Source
const OLS_MAX_SLOT uint = 64

Variables

This section is empty.

Functions

func OlsAlloc

func OlsAlloc() uint

func OlsFree

func OlsFree(slot uint)

func OlsInstallSlotCleanHandler

func OlsInstallSlotCleanHandler(slot uint, handler OlsSlotCleanHandler)

func SendOwn

func SendOwn(p *Object, c *Object) bool

func SendTerm

func SendTerm(o *Object) bool

func SendTermAck

func SendTermAck(p *Object) bool

func SendTermReq

func SendTermReq(p *Object, c *Object) bool

Types

type CmdStats

type CmdStats struct {
	PendingCnt int64
	SendCmdCnt int64
	RecvCmdCnt int64
}

type Command

type Command interface {
	Done(*Object) error
}

type CommandWrapper

type CommandWrapper func(*Object) error

func (CommandWrapper) Done

func (cw CommandWrapper) Done(o *Object) error

type Cond

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

func NewCond

func NewCond(waitor int) *Cond

func (*Cond) Broadcast

func (c *Cond) Broadcast()

func (*Cond) Drain

func (c *Cond) Drain()

func (*Cond) Signal

func (c *Cond) Signal()

func (*Cond) Wait

func (c *Cond) Wait()

func (*Cond) WaitForTick

func (c *Cond) WaitForTick(ticker *time.Ticker) bool

func (*Cond) WaitForTimeout

func (c *Cond) WaitForTimeout(dura time.Duration) bool

type IStatsWatch

type IStatsWatch interface {
	Stop()
}

type IStatsWatchMgr

type IStatsWatchMgr interface {
	WatchStart(name string, elementype int) IStatsWatch
}
var StatsWatchMgr IStatsWatchMgr

type Object

type Object struct {
	*utils.Waitor
	sync.RWMutex
	//  Identify
	Id int

	//  Name
	Name string

	//	UserData
	UserData interface{}
	// contains filtered or unexported fields
}
 Base class for need alone goroutine objects
 that easy to start and when to exit the unified management
	Feature.
		establish a tree structure between objects
		asynchronous message queue

func NewObject

func NewObject(id int, name string, opt Options, sinker Sinker) *Object

func (*Object) Active

func (o *Object) Active()

Active inner goroutine

func (*Object) GetChildById

func (o *Object) GetChildById(id int) *Object

thread safe

func (*Object) GetPendingCommandCnt

func (o *Object) GetPendingCommandCnt() int

func (*Object) GetStats

func (o *Object) GetStats() map[string]CmdStats

func (*Object) GetTreeName

func (o *Object) GetTreeName() string

func (*Object) IsTermiated

func (o *Object) IsTermiated() bool

func (*Object) LaunchChild

func (o *Object) LaunchChild(c *Object)

Launch the supplied object and become its owner.

func (*Object) OlsClrValue

func (o *Object) OlsClrValue()

func (*Object) OlsGetValue

func (o *Object) OlsGetValue(slot uint) interface{}

func (*Object) OlsSetValue

func (o *Object) OlsSetValue(slot uint, val interface{})

func (*Object) ProcessCommand

func (o *Object) ProcessCommand()

Dequeue command and process it.

func (*Object) ProcessSeqnum

func (o *Object) ProcessSeqnum()

Special handler called after a command that requires a seqnum was processed. The implementation should catch up with its counter of processed commands here.

func (*Object) SendCommand

func (o *Object) SendCommand(c Command, incseq bool) bool

Enqueue command

func (*Object) StatsSelf

func (o *Object) StatsSelf() (stats CmdStats)

func (*Object) Terminate

func (o *Object) Terminate(s *Object)

Ask owner object to terminate this object. It may take a while while actual termination is started. This function should not be called more than once.

type ObjectMonitor

type ObjectMonitor struct {
}

func (*ObjectMonitor) OnStart

func (om *ObjectMonitor) OnStart(o *Object)

func (*ObjectMonitor) OnStop

func (om *ObjectMonitor) OnStop(o *Object)

func (*ObjectMonitor) OnTick

func (om *ObjectMonitor) OnTick(o *Object)

type OlsSlotCleanHandler

type OlsSlotCleanHandler func(interface{})

type Options

type Options struct {
	//  HeartBeat interval
	Interval time.Duration
	//	The maximum number of processing each heartbeat
	MaxDone int
	//
	QueueBacklog int
}

type Sinker

type Sinker interface {
	OnStart()
	OnTick()
	OnStop()
}

Jump to

Keyboard shortcuts

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