loop

package
v0.0.0-...-491e284 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2022 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLoopClosed = errors.New(`loop already closed`)

Functions

This section is empty.

Types

type AsyncResult

type AsyncResult interface {
	OnResult(closed bool) (completed bool)
}

type Loop

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

func New

func New(scheduler Scheduler) *Loop

func (*Loop) Async

func (l *Loop) Async(w Worker) error

Create an asynchronous event, can only be called in the goroutine running by js

func (*Loop) Close

func (l *Loop) Close() (e error)

func (*Loop) Complete

func (l *Loop) Complete() error

Complete an asynchronous event, can only be called in the goroutine running by js

func (*Loop) Context

func (l *Loop) Context() context.Context

func (*Loop) Done

func (l *Loop) Done() <-chan struct{}

func (*Loop) GetScheduler

func (l *Loop) GetScheduler() Scheduler

func (*Loop) Go

func (l *Loop) Go(w Worker) error

go w.Serve()

func (*Loop) Result

func (l *Loop) Result(result AsyncResult) bool

Send the result of an asynchronous event to js

func (*Loop) Serve

func (l *Loop) Serve() (e error)

func (*Loop) SetScheduler

func (l *Loop) SetScheduler(scheduler Scheduler) Scheduler

func (*Loop) TryResult

func (l *Loop) TryResult(result AsyncResult) (ok bool)

type Scheduler

type Scheduler interface {
	Go(w Worker)
	Stop()
}

func NewScheduler

func NewScheduler(idle int) Scheduler

type Worker

type Worker interface {
	Serve()
}

func NewWorker

func NewWorker(f func()) Worker

Jump to

Keyboard shortcuts

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