co

package module
v0.0.0-...-a35ac31 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

README

co

coroutine library

A coroutine library to implement deterministic scheduling of concurrent processes.

Mostly inspired by Rob Pike's recursive state function type in his Lexical Scanning in Go talk.

I use this pattern a lot in the sb library, modeling stream/sink process as recursive functions.

Roadmap

  • I/O waiting. channel polling
  • threaded scheduler
  • prioritized scheduling

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proc

type Proc[V any] func(next *Proc[V]) V

Proc represents a procedure that returns a value and sets the next procedure

type Thread

type Thread[S any, V any] struct {
	// contains filtered or unexported fields
}

Thread represents a state and a procedure

func NewThread

func NewThread[S any, V any](
	initState S,
	initProc Proc[V],
) *Thread[S, V]

NewThread creates a new thread

func (*Thread[S, V]) Step

func (t *Thread[S, V]) Step() (v V, ok bool)

Step execute the thread in single step

Jump to

Keyboard shortcuts

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