loop

package
Version: v0.0.0-...-7821a71 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModuleID = `github.com/powerpuffpenguin/gojs/core/loop`
	LoopKey  = `loop`
)

Variables

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

Functions

func NewPromise

func NewPromise(runtime *goja.Runtime) goja.Value

func Require

func Require(runtime *goja.Runtime, module *goja.Object)

Types

type AsyncResult

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

type Future

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

func NewFuture

func NewFuture(loop *Loop, callable goja.Callable, this goja.Value) *Future

func (*Future) Async

func (a *Future) Async(w Worker)

func (*Future) Call

func (a *Future) Call(args ...goja.Value)

func (*Future) Complete

func (a *Future) Complete()

func (*Future) Context

func (a *Future) Context() context.Context

func (*Future) Done

func (a *Future) Done() <-chan struct{}

func (*Future) Go

func (a *Future) Go(w Worker)

func (*Future) Result

func (a *Future) Result(result AsyncResult)

func (*Future) TryResult

func (a *Future) TryResult(result AsyncResult) (ok bool)

type Loop

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

func Get

func Get(runtime *goja.Runtime) (loop *Loop)

func (*Loop) Async

func (l *Loop) Async(w Worker)

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()

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)

go w.Serve()

func (*Loop) Result

func (l *Loop) Result(result AsyncResult)

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()
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL