Documentation
¶
Overview ¶
Package barekit runs Bare worklets in process through a Bare Kit library loaded at runtime.
Index ¶
- type AndroidOptions
- type Error
- type Library
- type Options
- type Worklet
- func (w *Worklet) Close() error
- func (w *Worklet) CloseWrite() error
- func (w *Worklet) Read(b []byte) (int, error)
- func (w *Worklet) Resume() error
- func (w *Worklet) Suspend(linger time.Duration) error
- func (w *Worklet) Terminate() error
- func (w *Worklet) Wait() int
- func (w *Worklet) Wakeup(deadline time.Duration) error
- func (w *Worklet) Write(b []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AndroidOptions ¶
type AndroidOptions struct {
// JavaVM is the Java virtual machine, as a `JavaVM *`, which defaults to
// the one that loaded Bare Kit through `JNI_OnLoad()`.
JavaVM uintptr
// Context is the application context, as a JNI reference to an
// `android.content.Context`, which need only be valid for the call.
Context uintptr
}
AndroidOptions are the options of a worklet that apply on Android.
type Error ¶
type Error struct {
Status int
}
An Error is a call into Bare Kit that failed with Status.
type Library ¶
type Library struct {
// contains filtered or unexported fields
}
A Library is a loaded Bare Kit library, which stays loaded for as long as the process lives.
func Open ¶
Open loads the Bare Kit library at path, such as one downloaded with the prebuild package. On Android, path may name a library that the application bundles.
func (*Library) OptimizeForMemory ¶
OptimizeForMemory trades performance for memory. Must be configured before starting the first worklet.
type Options ¶
type Options struct {
// Args are passed to the worklet as `Bare.argv`.
Args []string
// Source is the source of the module, which is read from the filename if
// nil.
Source []byte
// MemoryLimit is the memory limit of each JavaScript heap in bytes, which
// is inferred from the amount of physical memory of the device if 0.
MemoryLimit int
// Android holds the options that apply on Android.
Android AndroidOptions
}
Options are the options of Library.Start.
type Worklet ¶
type Worklet struct {
// contains filtered or unexported fields
}
A Worklet is a Bare runtime running on a thread of its own, connected to its `Bare.IPC`.
Reading yields the data that the worklet writes to `Bare.IPC` until it ends its side of the connection, and writing sends data to it. One goroutine may read while another writes. CloseWrite ends the data sent to the worklet, while Close closes the connection and terminates the worklet.
func (*Worklet) Close ¶
Close closes the connection, terminating the worklet if it is still running, and releases its resources. Afterwards, Terminate does nothing and Suspend, Resume and Wakeup return io.ErrClosedPipe, while Wait still returns once the worklet has exited.
func (*Worklet) CloseWrite ¶
CloseWrite ends the data sent to the worklet, after which `Bare.IPC` reads end-of-stream while reading continues.
func (*Worklet) Read ¶
Read reads data that the worklet has written to `Bare.IPC`, returning io.EOF once it has ended its side of the connection.
func (*Worklet) Suspend ¶
Suspend suspends the worklet, emitting `suspend` on `Bare`. It keeps running for linger before going idle, or for as long as the platform allows if linger is negative.
func (*Worklet) Terminate ¶
Terminate asks the worklet to exit unless it has already exited or been closed.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
bare-kit-prebuild
command
Command bare-kit-prebuild downloads the prebuilt Bare Kit library of the version of this module and prints its path.
|
Command bare-kit-prebuild downloads the prebuilt Bare Kit library of the version of this module and prints its path. |
|
Package prebuild downloads the prebuilt Bare Kit libraries that the releases of this module provide.
|
Package prebuild downloads the prebuilt Bare Kit libraries that the releases of this module provide. |