concurrency

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2021 License: MIT Imports: 1 Imported by: 0

README

concurrency

The basic go concurrency implement.

Example

Example

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine implement a concurrent engine. You can use Engine do many tasks concurrent.

func New

func New(
	workerNum int,
	newWorkerFunc NewWorkerFunc,
) *Engine

func (*Engine) Close

func (e *Engine) Close()

Close close Engine, and you cant reuse or relaunch Engine.

func (*Engine) Run

func (e *Engine) Run()

Run is represent launch engine and listening context.

func (*Engine) Submit

func (e *Engine) Submit(ctx context.Context)

Submit a context to Engine, it will be received while any Worker ready.

type NewWorkerFunc

type NewWorkerFunc func() Worker

NewWorkerFunc represents the method to create a practical Worker.

type Worker

type Worker interface {
	Do(ctx context.Context)
}

Worker represents who can handle context.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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