{"id":"dig/parallel","name":"parallel","scope":"dig","platform":"roblox","description":"Parallel execution library for Roblox lua","version":"1.0.5","latest":"1.0.5","versions":["1.0.0","1.0.1","1.0.2","1.0.3","1.0.4","1.0.5"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{"evaera/promise":{"version":"^4.0.0","alias":"Promise"}},"integrity":"7cf508c2d346d3fdf153abfd969e8ae2346888345a291a491185051307962a15","likes":0,"downloads":0,"install":"forest install dig/parallel","url":"https://forest.dev/p/roblox/dig/parallel","files":"https://api.forest.dev/ai/package/roblox/dig/parallel/files","readme":"# roblox-lua-parallel\r\n\r\nA simple parallel execution library for Roblox lua. \r\n\r\nThis library uses Roblox actors to run tasks in parallel.\r\n\r\nRead more about Parallel Luau here: [Parallel Luau](https://create.roblox.com/docs/scripting/multithreading)\r\n\r\n## Installation\r\n\r\n### Method 1 - Wally\r\n1. Install [Wally](https://wally.run/install)\r\n2. Add the dependency to your project's `wally.toml` file\r\n```toml\r\n[dependencies]\r\nParallel = \"dig/parallel@1.0.4\"\r\n```\r\n3. Run `wally install`\r\n\r\n### Method 2 - Manual\r\n1. Download the `Parallel.rbxm` file from the latest release\r\n2. Drag it into your `ReplicatedStorage` folder\r\n\r\n## Basic Example\r\nThis example runs a function that returns \"Hello, world!\" in a new thread:\r\n```lua\r\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\r\nlocal Packages = ReplicatedStorage:WaitForChild(\"Packages\")\r\n\r\n-- Require parallel module\r\nlocal Parallel = require(Packages.Parallel)\r\n\r\n-- Prepare a thread with a runnable module script\r\n-- See below for ExampleHelloWorld.lua\r\nlocal preparedThread = Parallel.of(script.ExampleHelloWorld)\r\n\r\n-- Submit the thread and get the result via promise\r\nlocal result = preparedThread:submit():expect()\r\nprint(result) -- Prints \"Hello, world!\"\r\n\r\npreparedThread:destroy()\r\n```\r\n\r\nExampleHelloWorld.lua module script:\r\n```lua\r\nreturn function()\r\n  return \"Hello, world!\"\r\nend\r\n```\r\n\r\n## Advanced Example\r\nThis example runs spatial query function `GetPartBoundsInBox` in a new thread and returns the result:\r\n```lua\r\nlocal RunService = game:GetService(\"RunService\")\r\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\r\nlocal Packages = ReplicatedStorage:WaitForChild(\"Packages\")\r\n\r\n-- Require parallel module\r\nlocal Parallel = require(Packages.Parallel)\r\n\r\n-- Prepare a thread with a runnable module script\r\n-- See below for SpatialQuery.lua\r\nlocal preparedThread = Parallel.of(script.SpatialQuery)\r\n  :withName(\"SpatialQueryWorker\")\r\n  :withActors(2)\r\n\r\n-- Example zone of 200 x 200 x 200\r\nlocal zone = Instance.new(\"Part\")\r\nzone.Name = \"Zone\"\r\nzone.Position = Vector3.new(0, 0, 0)\r\nzone.Size = Vector3.new(200, 200, 200)\r\nzone.Anchored = true\r\nzone.CanCollide = true\r\nzone.Transparency = 0.8\r\nzone.Parent = workspace\r\n\r\nwhile RunService:IsRunning() do\r\n  -- Submit the thread and get the result via promise\r\n  local parts = preparedThread:submit(zone.CFrame, zone.Size):expect()\r\n  print(parts) -- Prints array of instances found inside the provided zone\r\n\r\n  task.wait(1)\r\nend\r\n\r\npreparedThread:destroy()\r\n```\r\n\r\nSpatialQuery.lua module script:\r\n```lua\r\nreturn function(position: CFrame, size: Vector3)\r\n  return workspace:GetPartBoundsInBox(position, size)\r\nend\r\n```","readmeTruncated":false}