WebWorkerCluster

class WebWorkerCluster(threads: Int, worker: String, parts: Int? = null, flags: Flags = Flags.defaults(), iceServers: Array<dynamic> = emptyArray())

A distributed solver in a browser: the catalog on the page, the workers on threads Web Workers, each running the script at worker (one calling startWebWorker with this module loaded) and a site of its own, a delegate of the one of the page (see Site.delegate). The theory is split into at most parts partitions if given, as many as the workers of the Web Workers and of the sites the cluster is federated with otherwise: it federates with JVM and Node.js sites over WebSockets (connect), lending them the workers of its Web Workers, and with the browsers they are linked to over WebRTC (see RtcLinks, with iceServers if given, as RTCPeerConnection takes them). The graph is labelled as the standard solver does with flags.

Constructors

Link copied to clipboard
constructor(threads: Int, worker: String, parts: Int? = null, flags: Flags = Flags.defaults(), iceServers: Array<dynamic> = emptyArray())

Properties

Link copied to clipboard

The flags of the solver, the initial ones those given: those set apply from the next evaluation on, the graph built anew, the links and the peers of the cluster kept

Link copied to clipboard
var onPeersChanged: () -> Unit?

Called whenever a site joins or leaves the peers of the cluster, its Web Workers included

Link copied to clipboard

The sites the cluster is federated with, its Web Workers included

Link copied to clipboard

The cluster as a solver of arg2p: any goal, its solutions and their graphs, the answers of queries

Link copied to clipboard

What the federation does, as the cluster knows it: the sites, and the last evaluation it answered (see Site.stats)

Functions

Link copied to clipboard
fun accept(invitation: String): Promise<String>

The reply to the invitation of another cluster, for it to complete the pairing

Link copied to clipboard
fun add(clause: String)

Adds clause, as Prolog text, to the theory

Link copied to clipboard
fun close()

Closes the links to the other sites, and stops the Web Workers

Link copied to clipboard
fun complete(reply: String): Promise<Unit>

The pairing invited completed with the reply of the other cluster: once the two are linked

Link copied to clipboard
fun connect(url: String, code: String? = null): Promise<Unit>

Federates the cluster with the site listening at url (ws://host:port), presenting code if it requires one

Link copied to clipboard

An invitation to pair with this cluster by hand, with no server between them: a code for another cluster to accept (see RtcLinks.invite)

Link copied to clipboard
fun load(theory: String)

Replaces the theory with theory, as Prolog text

Link copied to clipboard
fun reset()

Forgets the theory

Link copied to clipboard

The arguments for statement, as Prolog text, by label