v8worker2

package module
v0.0.0-...-78a7720 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: MIT Imports: 5 Imported by: 0

README

v8w

V8 Worker based on https://github.com/ry/v8worker2

Documentation

Overview

Copyright 2018 Ryan Dahl <ry@tinyclouds.org>. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveModule

func ResolveModule(moduleSpecifier *C.char, referrerSpecifier *C.char, resolverToken int) C.int

func SetFlags

func SetFlags(args []string) []string

Sets V8 flags. Returns the input args but with the V8 flags removed. Use --help to print a list of flags to stdout.

func Version

func Version() string

Return the V8 version E.G. "6.6.164-v8worker2"

Types

type ModuleResolverCallback

type ModuleResolverCallback func(moduleName, referrerName string) int

To resolve modules from javascript.

type ReceiveMessageCallback

type ReceiveMessageCallback func(msg []byte) []byte

To receive messages from javascript.

type Worker

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

This is a golang wrapper around a single V8 Isolate.

func New

Creates a new worker, which corresponds to a V8 isolate. A single threaded standalone execution context.

func (*Worker) Dispose

func (w *Worker) Dispose()

Forcefully frees up memory associated with worker. GC will also free up worker memory so calling this isn't strictly necessary.

func (*Worker) Load

func (w *Worker) Load(scriptName string, code string) error

Load and executes a javascript file with the filename specified by scriptName and the contents of the file specified by the param code.

func (*Worker) LoadModule

func (w *Worker) LoadModule(scriptName string, code string, resolve ModuleResolverCallback) error

LoadModule loads and executes a javascript module with filename specified by scriptName and the contents of the module specified by the param code. All `import` dependencies must be loaded before a script otherwise it will error.

func (*Worker) SendBytes

func (w *Worker) SendBytes(msg []byte) error

Same as Send but for []byte. $recv callback will get an ArrayBuffer.

func (*Worker) TerminateExecution

func (w *Worker) TerminateExecution()

Terminates execution of javascript

Jump to

Keyboard shortcuts

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