vmpool

package
v0.0.0-...-17003a6 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool interface {
	// Pop gets a vm.VM from Pool concurrent-safely
	// if it's implement in no-block way, it may return nil
	Pop() vm.VM

	// Push sets a vm.WorkerVM to Pool concurrent-safely.
	Push(vm.VM)

	// Walk try to apply each vm.VM with wf until wf return false or all vm.WorkerVM in Pool have been applied.
	Walk(wf func(v vm.VM) (terminal bool))

	// Close close all vm.WorkerVM in Pool.
	Close()
}

Pool is the reusable vm.VM pool, Pop and Push is concurrent-safe

type PoolImpl

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

PoolImpl implement Pool.

func NewPoolImpl

func NewPoolImpl(workerID int64, cap int64) (*PoolImpl, error)

NewPoolImpl create PoolImpl.

func (*PoolImpl) Close

func (p *PoolImpl) Close()

Close close all vm.WorkerVM in Pool.

func (*PoolImpl) Pop

func (p *PoolImpl) Pop() (worker vm.VM)

Pop gets a vm.VM from Pool concurrent-safely if it's implement in no-block way, it may return nil.

func (*PoolImpl) Push

func (p *PoolImpl) Push(worker vm.VM)

Push sets a vm.WorkerVM to Pool concurrent-safely.

func (*PoolImpl) Walk

func (p *PoolImpl) Walk(wf func(v vm.VM) bool)

Walk try to apply each vm.VM with wf until wf return false or all vm.WorkerVM in Pool have been applied

Jump to

Keyboard shortcuts

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