coroutine

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCannotYieldANonrunningThread = errors.New("can not yield a non-running thread")

ErrCannotYieldANonrunningThread represents an "can not yield a non-running thread" error.

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 added in v1.0.0

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 added in v1.0.0

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

func (*Coroutines) StopIf added in v1.0.0

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 added in v0.8.0

type ThreadObj interface {
}

Jump to

Keyboard shortcuts

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