actualCombat

package
v0.0.0-...-db5681a Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPoolNotExist  = errors.New("pool not exist")
	ErrGetResTimeout = errors.New("get resource time out")
)

Functions

This section is empty.

Types

type Pool

type Pool chan *Resource

对象池

func New

func New(size int) Pool

并发创建资源对象,节省资源对象初始化时间

func (Pool) GetResource

func (p Pool) GetResource() (r *Resource, err error)

从获取对象池获取对象

func (Pool) GiveBackResource

func (p Pool) GiveBackResource(r *Resource) error

将资源返回到资源池

type Resource

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

资源类

func NewResource

func NewResource(id int) *Resource

初始化资源对象 模拟缓慢的资源访问,例如,TCP 连接等

func (*Resource) Do

func (r *Resource) Do(workId int)

模拟资源耗时

Jump to

Keyboard shortcuts

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