pool

package
v0.0.0-...-66c0836 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasePoolManager

type BasePoolManager struct {
	run.BaseWorker
	WorkPool      IPool
	SelfPoolChain chan interface{}
}

*

管理池基本类
要实现池,只需要继承该结构,并实现自定义的创建方法

func (BasePoolManager) GetId

func (t BasePoolManager) GetId() uint32

*************for IPoolManager******************

func (BasePoolManager) GetName

func (t BasePoolManager) GetName() string

func (*BasePoolManager) Init

func (t *BasePoolManager) Init() error

func (*BasePoolManager) Run

func (t *BasePoolManager) Run() error

type BasePoolWorker

type BasePoolWorker struct {
	run.BaseWorker
	WorkChain chan interface{}
	WorkPool  IPoolManager
}

*

基本的工作线程类  需要自己定义run方法

func (BasePoolWorker) GetId

func (t BasePoolWorker) GetId() uint32

*********** for IPoolWorker**********************

func (BasePoolWorker) GetName

func (t BasePoolWorker) GetName() string

func (*BasePoolWorker) Init

func (this *BasePoolWorker) Init() error

func (*BasePoolWorker) Run

func (this *BasePoolWorker) Run() error

func (*BasePoolWorker) SendToWorkChain

func (this *BasePoolWorker) SendToWorkChain(msg interface{})

func (*BasePoolWorker) SetWorkChain

func (this *BasePoolWorker) SetWorkChain(ch chan interface{}) bool

func (*BasePoolWorker) SetWorkPool

func (this *BasePoolWorker) SetWorkPool(pl IPoolManager)

type IPool

type IPool interface {
	Take() (IPoolWorker, error)
	Return(entity IPoolWorker) error
	GetTotal() uint32
	GetUsed() uint32
}

func NewPool

func NewPool(total uint32, genEntity func() IPoolWorker) (IPool, error)

创建实体池。

type IPoolBase

type IPoolBase interface {
	GetId() uint32
	GetName() string
	Init() error
	Run() error
}

type IPoolManager

type IPoolManager interface {
	IPoolBase
}

type IPoolWorker

type IPoolWorker interface {
	IPoolBase
	SetWorkChain(ch chan interface{}) bool
	SetWorkPool(pl IPoolManager)
	SendToWorkChain(msg interface{})
}

type Pool

type Pool struct {
	Total     uint32
	Etype     reflect.Type
	GenEntity func() IPoolWorker

	IdContainer map[uint32]bool
	// contains filtered or unexported fields
}

func (Pool) GetTotal

func (t Pool) GetTotal() uint32

func (Pool) GetUsed

func (t Pool) GetUsed() uint32

func (*Pool) Return

func (this *Pool) Return(entity IPoolWorker) error

func (*Pool) Take

func (this *Pool) Take() (IPoolWorker, error)

Jump to

Keyboard shortcuts

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