Overview

A lightweight library that simplifies parallel execution of multiple functions with automatic batching to prevent system overload. Ideal for processing multiple independent tasks concurrently.

Installation

Install the library using gfetch:

gfetch manaphoenix/CC-Code/main/lib/parallelActions.lua
Alternative: Use wget
wget https://raw.githubusercontent.com/manaphoenix/CC-Code/main/lib/parallelActions.lua

Basic Usage

Queue up functions to be executed in parallel, with automatic batching to prevent system overload.

lua Basic Usage
local parallelAction = require("parallelAction")

-- Add some actions
for i = 1, 10 do
    parallelAction.addAction(function()
        -- Some work here
        print("Processing item " .. i)
    end)
end

-- Execute all actions
parallelAction.execute("Batch processing")

Methods

setBatchSize ( size: number ) : void

Sets the maximum number of actions to execute in a single batch.

Example Code
lua
module.setBatchSize(50) -- works
module.setBatchSize("50") -- errors, must be a number
module.setBatchSize(256) -- errors, must be 255 or less
module.setBatchSize(1.05) -- errors, must be an integer

addAction ( action: function ) : void

Adds an action to the queue of actions to be executed.

Example Code
lua
local function someAction()
    print("Processing item")
end

module.addAction(someAction)

execute ( optStr: string, verbose: boolean ) : void

Executes all queued actions in parallel, handling batching automatically.

Example Code
lua
-- your code here

module.execute("Batch processing", true) -- "Name" is optional, "verbose" is optional
-- with verbose true, it will print the name of the batch and when it finished