Multiprocess
Multiprocessing Manager
Multiprocessing is a powerful package enabling developers to spawn EVM instances for parallel processing, similar to starting new threads in other general-purpose languages. It overcomes the limitations of the single-threaded design in EVM.
The module offers a queue, which temporarily holds a list of tasks before execution begins. State consistency is rigorously guaranteed all the time.
Contract
The Multiprocess contract
inherits from "Base" and "Revertible" contracts. It serves as a container for executable messages, enabling parallel processing more similar to Python's multiprocessing
library.
Constructor
constructor (uint256 threads)
Constructor to initialize the Multiprocess container.
Parameters:
processes
: The number of parallel proceses(ranging from 1 to 255) for parallel processing.
Public Functions
push
Push an executable message into the container with specified gas limit, contract address, and function call data.
Parameters:
gaslimit
: The gas limit for the execution of the function call.contractAddr
: The address of the smart contract to execute the function on.funcCall
: The encoded function call data.
push
Push an executable message into the container with specified gas limit, eth value, contract address, and function call data.
Parameters:
gaslimit
: The gas limit for the execution of the function call.ethVal
: The number of wei sent with the message.contractAddr
: The address of the smart contract to execute the function on.funcCall
: The encoded function call data.
pop
Pop an executable message from the container.
Returns:
bytes
: The popped executable message.
get
Get an executable message from the container at the specified index.
Parameters:
idx
: The index of the executable message to retrieve.
Returns:
bytes
: The executable message at the specified index.
set
Set an executable message at the specified index in the container.
Parameters:
idx
: The index where the executable message should be stored.elem
: The executable message data to be stored at the specified index.
run
This function processes the executable messages concurrently with the number of threads specified in the constructor.
Note: Executions causing potential state inconsistency will be reverted automatically. This is guaranteed at the system level.
License
The contract is licensed under the GPL-3.0 license.
Last updated