Skip to Content
Skip to Content

Multi Threading

zune.thread


A library to create multiple lua states and execute in parallel.

Properties

isThread

The current context of running program.

isThread: boolean

Functions

fromModule

Creates a new thread from a module. Resolves relative to the calling module.

fromModule(module: string): Thread

Parameters

  • module: string - The module to load in the new thread.

Throws

  • Luau Error
  • Require Error
  • Memory Error

fromBytecode

Creates a new thread from bytecode.

fromBytecode(bytecode: string | buffer, opts: export type ThreadLoadOptions = { chunk_name: string?, native_code_gen: boolean?, }ThreadLoadOptionsexport type ThreadLoadOptions = { chunk_name: string?, native_code_gen: boolean?, }?): Thread

Parameters

  • bytecode: string | buffer - The bytecode to load in the new thread.
  • opts: ThreadLoadOptions? - The options for loading the bytecode.
    • chunk_name: string?
      • default: "(thread)"
    • native_code_gen: boolean?
      • default: true

Throws

  • Luau Error
  • Memory Error

receive

Receives a message from the owner thread.

Will error if called from the main thread.

receive(): ...any

Throws

  • Thread Error
  • Memory Error

send

Sends a message to the owner thread.

Will error if called from the main thread.

send(...any): ()

Parameters

  • ...any - The values to send to the owner thread.

Throws

  • Thread Error
  • Memory Error

getCpuCount

Gets the number of CPU cores available. If the number cannot be determined, it will return 1.

getCpuCount(): number
Last updated on