mpool

package
v0.0.0-...-c9d2d86 Latest Latest
Warning

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

Go to latest
Published: May 25, 2018 License: ISC Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrVMAlreadyRunning = errors.New("vm have been running ...")
	ErrVMNotRunning     = errors.New("vm not running")
	ErrJobNotFunc       = errors.New("job not function")
	ErrWorkerClosed     = errors.New("worker closed")
	ErrWorkerTimeout    = errors.New("worker timeout")
)

start vm(lua and js service according to configure) manage the all worker instance

Functions

This section is empty.

Types

type VirtualMachine

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

func CreateCustomVM

func CreateCustomVM(workers []VmWorker) *VirtualMachine

func CreateGenericVM

func CreateGenericVM(numWorkers int, fn func(interface{}) interface{}) *VirtualMachine

func CreateVM

func CreateVM(numWorkers int, job func(interface{}) interface{}) *VirtualMachine

func (*VirtualMachine) Close

func (vm *VirtualMachine) Close(name string) error

func (*VirtualMachine) IsRunning

func (vm *VirtualMachine) IsRunning() bool

func (*VirtualMachine) Loop

func (vm *VirtualMachine) Loop()

func (*VirtualMachine) NumPendingAsycnJobs

func (vm *VirtualMachine) NumPendingAsycnJobs() int32

func (*VirtualMachine) NumWorkers

func (vm *VirtualMachine) NumWorkers() int

func (*VirtualMachine) Open

func (vm *VirtualMachine) Open(name string) (*VirtualMachine, error)

func (*VirtualMachine) SendWork

func (vm *VirtualMachine) SendWork(jobData interface{}) (interface{}, error)

func (*VirtualMachine) SendWorkAsync

func (vm *VirtualMachine) SendWorkAsync(jobData interface{}, callback func(interface{}, error))

func (*VirtualMachine) SendWorkClean

func (vm *VirtualMachine) SendWorkClean(jobData interface{}) (interface{}, error)

func (*VirtualMachine) SendWorkCleanAsync

func (vm *VirtualMachine) SendWorkCleanAsync(jobData interface{}) error

func (*VirtualMachine) SendWorkTimed

func (vm *VirtualMachine) SendWorkTimed(timeout time.Duration, jobData interface{}) (interface{}, error)

func (*VirtualMachine) SendWorkTimedAsync

func (vm *VirtualMachine) SendWorkTimedAsync(timeout time.Duration, jobData interface{}, callback func(interface{}, error))

type VmDefaultWorker

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

the vm DefaultWorker

func (*VmDefaultWorker) VmJob

func (worker *VmDefaultWorker) VmJob(data interface{}) (interface{}, error)

func (*VmDefaultWorker) VmReady

func (worker *VmDefaultWorker) VmReady() bool

type VmExtendedWorker

type VmExtendedWorker interface {
	// when the mechine is opened and closed, the will be implemented.
	VmInitialize()
	VmTerminate()
}

type VmInterruptableWorker

type VmInterruptableWorker interface {
	//called by the client that will be killed this worker
	VmInterruptable()
}

type VmWorker

type VmWorker interface {
	//called for job, adn returned synchronously
	VmJob(interface{}) (interface{}, error)

	//wait for to execute the next job
	VmReady() bool
}

Jump to

Keyboard shortcuts

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