v8worker

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

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

Go to latest
Published: May 14, 2018 License: MIT Imports: 5 Imported by: 8

README

This project has been updated with an improved API: https://github.com/ry/v8worker2

The code here will not be updated.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Version

func Version() string

Return the V8 version E.G. "4.3.59"

Types

type ReceiveMessageCallback

type ReceiveMessageCallback func(msg string)

To receive messages from javascript...

type ReceiveSyncMessageCallback

type ReceiveSyncMessageCallback func(msg string) string

To send a message from javascript and synchronously return a string.

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

func (w *Worker) Send(msg string) error

Sends a message to a worker. The $recv callback in js will be called.

func (*Worker) SendSync

func (w *Worker) SendSync(msg string) string

SendSync sends a message to a worker. The $recvSync callback in js will be called. That callback will return a string which is passed to golang and used as the return value of SendSync.

func (*Worker) TerminateExecution

func (w *Worker) TerminateExecution()

Terminates execution of javascript

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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