nodeWorkerThreadsMod

class Object
trait Matchable
class Any

Type members

Classlikes

@JSImport("node:worker_threads", "BroadcastChannel") @native @JSType

See https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel

@JSImport("node:worker_threads", "MessageChannel") @native @JSType
@JSImport("node:worker_threads", "MessagePort") @native @JSType
class MessagePort() extends StObject
@JSImport("node:worker_threads", "Worker") @native @JSType
class Worker extends StObject

Value members

Concrete methods

@inline
Value Params
key

Any arbitrary, cloneable JavaScript value that can be used as a {Map} key.

@inline
def markAsUntransferable(`object`: Object): Unit

Mark an object as not transferable. If object occurs in the transfer list of a port.postMessage() call, it will be ignored.

Mark an object as not transferable. If object occurs in the transfer list of a port.postMessage() call, it will be ignored.

In particular, this makes sense for objects that can be cloned, rather than transferred, and which are used by other objects on the sending side. For example, Node.js marks the ArrayBuffers it uses for its Buffer pool with this.

This operation cannot be undone.

@inline

Transfer a MessagePort to a different vm Context. The original port object will be rendered unusable, and the returned MessagePort instance will take its place.

Transfer a MessagePort to a different vm Context. The original port object will be rendered unusable, and the returned MessagePort instance will take its place.

The returned MessagePort will be an object in the target context, and will inherit from its global Object class. Objects passed to the port.onmessage() listener will also be created in the target context and inherit from its global Object class.

However, the created MessagePort will no longer inherit from EventEmitter, and only port.onmessage() can be used to receive events using it.

@inline

Receive a single message from a given MessagePort. If no message is available, undefined is returned, otherwise an object with a single message property that contains the message payload, corresponding to the oldest message in the MessagePort’s queue.

Receive a single message from a given MessagePort. If no message is available, undefined is returned, otherwise an object with a single message property that contains the message payload, corresponding to the oldest message in the MessagePort’s queue.

@inline
Value Params
key

Any arbitrary, cloneable JavaScript value that can be used as a {Map} key.

value

Any arbitrary, cloneable JavaScript value that will be cloned and passed automatically to all new Worker instances. If value is passed as undefined, any previously set value for the key will be deleted.

Concrete fields

@JSImport("node:worker_threads", "SHARE_ENV") @native
val SHARE_ENV: Symbol
@JSImport("node:worker_threads") @native
val ^: Any
@JSImport("node:worker_threads", "isMainThread") @native
val isMainThread: Boolean
@JSImport("node:worker_threads", "parentPort") @native
val parentPort: Null | MessagePort
@JSImport("node:worker_threads", "resourceLimits") @native
@JSImport("node:worker_threads", "threadId") @native
val threadId: Double
@JSImport("node:worker_threads", "workerData") @native
val workerData: Any