cogo

package
v0.0.0-...-3ca3cf1 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasGen

func HasGen() bool

Types

type Coroutine

type Coroutine[InT, OutT any] struct {
	State    int32
	SubState int32
	In       InT
	Out      OutT
	Func     CoroutineFunc[InT, OutT]
	Yielder  Yielder
}

func New

func New[InT, OutT any](coro CoroutineFunc[InT, OutT], input InT) (c *Coroutine[InT, OutT])

func (*Coroutine[InT, OutT]) Begin

func (c *Coroutine[InT, OutT]) Begin()

func (*Coroutine[InT, OutT]) Tick

func (c *Coroutine[InT, OutT]) Tick() (done bool)

func (*Coroutine[InT, OutT]) Yield

func (c *Coroutine[InT, OutT]) Yield(out OutT)

Yield yields and sets the Out variable to the passed variable

func (*Coroutine[InT, OutT]) YieldNone

func (c *Coroutine[InT, OutT]) YieldNone()

YieldNone yields without updating the Out variable

func (*Coroutine[InT, OutT]) YieldTo

func (c *Coroutine[InT, OutT]) YieldTo(y Yielder)

YieldTo gives control to a Yielder object and immediately executes one Tick on it. Future 'Tick' calls on the original coroutine will run 'Tick' on passed Yielder.

The original coroutine will only resume execution once this yielder reports that its done

type CoroutineFunc

type CoroutineFunc[InT, OutT any] func(c *Coroutine[InT, OutT])

type Sleeper

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

func NewSleeper

func NewSleeper(sleepDuration time.Duration) *Sleeper

NewSleeper returns a sleeper that is done after at least sleepDuration time has passed

func (*Sleeper) Tick

func (s *Sleeper) Tick() bool

type Yielder

type Yielder interface {
	Tick() (done bool)
}

Jump to

Keyboard shortcuts

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