coroutine

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCannotYieldANonrunningThread represents an "can not yield a non-running thread" error.
	ErrCannotYieldANonrunningThread = errors.New("can not yield a non-running thread")
	ErrAbortThread                  = errors.New("abort thread")
)

Functions

This section is empty.

Types

type Coroutines

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

Coroutines represents a coroutine manager.

func New

func New() *Coroutines

New creates a coroutine manager.

func (*Coroutines) Abort

func (p *Coroutines) Abort()

func (*Coroutines) Create

func (p *Coroutines) Create(tobj ThreadObj, fn func(me Thread) int) Thread

Create creates a new coroutine.

func (*Coroutines) CreateAndStart

func (p *Coroutines) CreateAndStart(start bool, tobj ThreadObj, fn func(me Thread) int) Thread

CreateAndStart creates and executes the new coroutine.

func (*Coroutines) Current

func (p *Coroutines) Current() Thread

func (*Coroutines) Resume

func (p *Coroutines) Resume(th Thread)

Resume resumes a suspended coroutine.

func (*Coroutines) Sched

func (p *Coroutines) Sched(me Thread)

Sched func.

func (*Coroutines) Sleep

func (p *Coroutines) Sleep(t time.Duration)

func (*Coroutines) StopIf

func (p *Coroutines) StopIf(filter func(th Thread) bool)

func (*Coroutines) Yield

func (p *Coroutines) Yield(me Thread)

Yield suspends a running coroutine.

type Thread

type Thread = *threadImpl

Thread represents a coroutine id.

type ThreadObj

type ThreadObj interface {
}

Jump to

Keyboard shortcuts

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