workermod

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package workermod is the native module "worker": workers are Kukel interpreters that run in parallel, each on its own goroutine, and talk to the interpreter that started them only through messages.

use worker;

square(id) {                        // runs in the worker
    for (local m = worker::receive(); m != nil; m = worker::receive())
        worker::send([id, m * m]);
}

main() {
    local w = worker::start(square, 1);   // or worker::startfile("sq.kkl", ...)
    w->send(7);
    println(w->receive());                // [1, 49]
    w->stop();                            // the worker's receive() gives nil
    w->wait();
}

Interpreters share nothing: a message is a copy, made by the sender, of a boolean, a number, a string, or vectors and maps of those (and nil inside them; nil itself cannot be sent, receive gives it at the end).

Index

Constants

This section is empty.

Variables

View Source
var Worker = &native.Class{Name: "Worker"}

Worker is the class worker::Worker: the parent's handle of a worker.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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