V15.3.0 #46
26
README.md
26
README.md
@ -1,4 +1,4 @@
|
|||||||
# Multi Version: 16.0.0 Upgrade Complete
|
# Multi Version: 15.2.0 Upgrade Complete
|
||||||
**Key Changes**
|
**Key Changes**
|
||||||
- All objects now use connections internally
|
- All objects now use connections internally
|
||||||
- Updated getTasksDetails() to handle the new method of managing threads and processors
|
- Updated getTasksDetails() to handle the new method of managing threads and processors
|
||||||
@ -9,16 +9,13 @@ My multitasking library for lua. It is a pure lua binding, with exceptions of th
|
|||||||
|
|
||||||
INSTALLING
|
INSTALLING
|
||||||
----------
|
----------
|
||||||
Links to dependencies:
|
Link to dependencies:
|
||||||
[lanes](https://github.com/LuaLanes/lanes)
|
[lanes](https://github.com/LuaLanes/lanes)
|
||||||
|
|
||||||
To install copy the multi folder into your environment and you are good to go</br>
|
To install copy the multi folder into your environment and you are good to go</br>
|
||||||
If you want to use the system threads, then you'll need to install lanes!
|
If you want to use the system threads, then you'll need to install lanes!
|
||||||
**or** use luarocks `luarocks install multi`
|
**or** use luarocks `luarocks install multi`
|
||||||
|
|
||||||
Going forward I will include a Release zip for love2d.
|
|
||||||
**The Network Manager rework is currently being worked on and the old version is not included in this version.**
|
|
||||||
|
|
||||||
Discord
|
Discord
|
||||||
-------
|
-------
|
||||||
Have a question? Or need realtime assistance? Feel free to join the discord!</br>
|
Have a question? Or need realtime assistance? Feel free to join the discord!</br>
|
||||||
@ -26,7 +23,6 @@ https://discord.gg/U8UspuA</br>
|
|||||||
|
|
||||||
Planned features/TODO
|
Planned features/TODO
|
||||||
---------------------
|
---------------------
|
||||||
- [x] ~~Finish Documentation~~ Finished
|
|
||||||
- [ ] Create test suite
|
- [ ] Create test suite
|
||||||
- [ ] Network Parallelism rework
|
- [ ] Network Parallelism rework
|
||||||
|
|
||||||
@ -34,21 +30,27 @@ Usage: [Check out the documentation for more info](https://github.com/rayaman/mu
|
|||||||
-----
|
-----
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
|
||||||
local multi, thread = require("multi"):init()
|
local multi, thread = require("multi"):init()
|
||||||
GLOBAL, THREAD = require("multi.integration.threading"):init()
|
GLOBAL, THREAD = require("multi.integration.lanesManager"):init()
|
||||||
multi:newSystemThread("System Thread",function()
|
multi:newSystemThread("System Thread",function()
|
||||||
while true do
|
while true do
|
||||||
THREAD.sleep(1)
|
THREAD.sleep(.1)
|
||||||
print("World!")
|
io.write(" World")
|
||||||
|
THREAD.kill()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
multi:newThread("Coroutine Based Thread",function()
|
multi:newThread("Coroutine Based Thread",function()
|
||||||
while true do
|
while true do
|
||||||
print("Hello")
|
io.write("Hello")
|
||||||
thread.sleep(1)
|
thread.sleep(.1)
|
||||||
|
thread.kill()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
multi:newTLoop(function(loop)
|
||||||
|
print("!")
|
||||||
|
loop:Destroy()
|
||||||
|
os.exit()
|
||||||
|
end,.3)
|
||||||
multi:mainloop()
|
multi:mainloop()
|
||||||
--[[
|
--[[
|
||||||
while true do
|
while true do
|
||||||
|
|||||||
42
changes.md
42
changes.md
@ -15,7 +15,7 @@ Added:
|
|||||||
---
|
---
|
||||||
|
|
||||||
- multi:newTLoop() member functions
|
- multi:newTLoop() member functions
|
||||||
- `Loop:Set(set)` - Sets the time to wait for the TLoop
|
- `TLoop:Set(set)` - Sets the time to wait for the TLoop
|
||||||
|
|
||||||
- multi:newStep() member functions
|
- multi:newStep() member functions
|
||||||
- `Step:Count(count)` - Sets the amount a step should count by
|
- `Step:Count(count)` - Sets the amount a step should count by
|
||||||
@ -30,7 +30,6 @@ Changed:
|
|||||||
- Connection Objects now pass on the parent object if created on a multiobj. This was to allow chaining to work properly with the new update
|
- Connection Objects now pass on the parent object if created on a multiobj. This was to allow chaining to work properly with the new update
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
|
||||||
multi,thread = require("multi"):init()
|
multi,thread = require("multi"):init()
|
||||||
|
|
||||||
loop = multi:newTLoop()
|
loop = multi:newTLoop()
|
||||||
@ -39,7 +38,6 @@ Changed:
|
|||||||
print("testing haha")
|
print("testing haha")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
loop:Set(1)
|
loop:Set(1)
|
||||||
t = loop:OnLoop(function()
|
t = loop:OnLoop(function()
|
||||||
print("Looping...")
|
print("Looping...")
|
||||||
@ -97,8 +95,7 @@ ToDo:
|
|||||||
Full Update Showcase
|
Full Update Showcase
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
package.path = "./?/init.lua;"..package.path
|
local multi,thread = require("multi"):init()
|
||||||
multi,thread = require("multi"):init()
|
|
||||||
|
|
||||||
func = thread:newFunction(function(count)
|
func = thread:newFunction(function(count)
|
||||||
local a = 0
|
local a = 0
|
||||||
@ -197,9 +194,7 @@ Added:
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
```lua
|
```lua
|
||||||
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
local multi,thread = require("multi"):init()
|
||||||
package.cpath = [[C:\Program Files (x86)\Lua\5.1\systree\lib\lua\5.1\?.dll;C:\Program Files (x86)\Lua\5.1\systree\lib\lua\5.1\?\core.dll;]] ..package.cpath
|
|
||||||
multi,thread = require("multi"):init()
|
|
||||||
GLOBAL,THREAD = require("multi.integration.threading"):init() -- Auto detects your enviroment and uses what's available
|
GLOBAL,THREAD = require("multi.integration.threading"):init() -- Auto detects your enviroment and uses what's available
|
||||||
|
|
||||||
jq = multi:newSystemThreadedJobQueue(5) -- Job queue with 4 worker threads
|
jq = multi:newSystemThreadedJobQueue(5) -- Job queue with 4 worker threads
|
||||||
@ -244,8 +239,7 @@ multi:mainloop()
|
|||||||
## multi:newProcessor(name)
|
## multi:newProcessor(name)
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
package.path = "./?/init.lua;"..package.path
|
local multi,thread = require("multi"):init()
|
||||||
multi,thread = require("multi"):init()
|
|
||||||
|
|
||||||
-- Create a processor object, it works a lot like the multi object
|
-- Create a processor object, it works a lot like the multi object
|
||||||
sandbox = multi:newProcessor()
|
sandbox = multi:newProcessor()
|
||||||
@ -318,8 +312,7 @@ Can be chained as long as you want! See example below
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
package.path = "./?/init.lua;"..package.path
|
local multi,thread = require("multi"):init()
|
||||||
multi,thread = require("multi"):init()
|
|
||||||
|
|
||||||
func = thread:newFunction(function(count)
|
func = thread:newFunction(function(count)
|
||||||
local a = 0
|
local a = 0
|
||||||
@ -374,8 +367,7 @@ Changed:
|
|||||||
holdMe(set) | Sets the holdme argument that existed at function creation
|
holdMe(set) | Sets the holdme argument that existed at function creation
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
package.path = "./?/init.lua;"..package.path
|
local multi, thread = require("multi"):init()
|
||||||
multi, thread = require("multi"):init()
|
|
||||||
|
|
||||||
test = thread:newFunction(function(a,b)
|
test = thread:newFunction(function(a,b)
|
||||||
thread.sleep(1)
|
thread.sleep(1)
|
||||||
@ -469,8 +461,7 @@ ToDo
|
|||||||
Full Update Showcase
|
Full Update Showcase
|
||||||
---
|
---
|
||||||
```lua
|
```lua
|
||||||
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
local multi,thread = require("multi"):init()
|
||||||
multi,thread = require("multi"):init()
|
|
||||||
GLOBAL,THREAD = require("multi.integration.threading"):init() -- Auto detects your enviroment and uses what's available
|
GLOBAL,THREAD = require("multi.integration.threading"):init() -- Auto detects your enviroment and uses what's available
|
||||||
|
|
||||||
jq = multi:newSystemThreadedJobQueue(4) -- Job queue with 4 worker threads
|
jq = multi:newSystemThreadedJobQueue(4) -- Job queue with 4 worker threads
|
||||||
@ -540,7 +531,6 @@ Todo:
|
|||||||
Full Update Showcase
|
Full Update Showcase
|
||||||
---
|
---
|
||||||
```lua
|
```lua
|
||||||
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
|
||||||
local multi,thread = require("multi"):init()
|
local multi,thread = require("multi"):init()
|
||||||
|
|
||||||
-- Testing destroying and fixed connections
|
-- Testing destroying and fixed connections
|
||||||
@ -607,7 +597,6 @@ Fixed:
|
|||||||
- Issue with connections not returning a handle for managing a specific conn object.
|
- Issue with connections not returning a handle for managing a specific conn object.
|
||||||
- Issue with connections where connection chaining wasn't working properly. This has been addressed.
|
- Issue with connections where connection chaining wasn't working properly. This has been addressed.
|
||||||
```lua
|
```lua
|
||||||
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
|
||||||
local multi,thread = require("multi"):init()
|
local multi,thread = require("multi"):init()
|
||||||
test = multi:newConnection()
|
test = multi:newConnection()
|
||||||
test(function(hmm)
|
test(function(hmm)
|
||||||
@ -660,7 +649,6 @@ Full Update Showcase
|
|||||||
---
|
---
|
||||||
Something I plan on doing each version going forward
|
Something I plan on doing each version going forward
|
||||||
```lua
|
```lua
|
||||||
package.path="?.lua;?/init.lua;?.lua;"..package.path
|
|
||||||
local multi, thread = require("multi"):init()
|
local multi, thread = require("multi"):init()
|
||||||
GLOBAL,THREAD = require("multi.integration.lanesManager"):init()
|
GLOBAL,THREAD = require("multi.integration.lanesManager"):init()
|
||||||
serv = multi:newService(function(self,data)
|
serv = multi:newService(function(self,data)
|
||||||
@ -897,7 +885,6 @@ Added:
|
|||||||
- thread.hold() and multi.hold() now accept connections as an argument. See example below
|
- thread.hold() and multi.hold() now accept connections as an argument. See example below
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
package.path = "./?/init.lua;"..package.path
|
|
||||||
local multi, thread = require("multi"):init()
|
local multi, thread = require("multi"):init()
|
||||||
conn = multi:newConnection()
|
conn = multi:newConnection()
|
||||||
multi:newThread(function()
|
multi:newThread(function()
|
||||||
@ -928,7 +915,6 @@ end)
|
|||||||
|
|
||||||
thread newFunction using auto convert
|
thread newFunction using auto convert
|
||||||
```lua
|
```lua
|
||||||
package.path = "./?/init.lua;" .. package.path
|
|
||||||
multi, thread = require("multi").init()
|
multi, thread = require("multi").init()
|
||||||
a=5
|
a=5
|
||||||
multi:newThread("Test",function()
|
multi:newThread("Test",function()
|
||||||
@ -966,7 +952,7 @@ Changed:
|
|||||||
---
|
---
|
||||||
- Connections connect function can now chain connections
|
- Connections connect function can now chain connections
|
||||||
```lua
|
```lua
|
||||||
package.path = "./?/init.lua;"..package.path
|
|
||||||
local multi, thread = require("multi").init()
|
local multi, thread = require("multi").init()
|
||||||
test = multi:newConnection()
|
test = multi:newConnection()
|
||||||
test(function(a)
|
test(function(a)
|
||||||
@ -1164,7 +1150,6 @@ Added:
|
|||||||
- STC: FireTo(id,...) — Described above.
|
- STC: FireTo(id,...) — Described above.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
package.path="?/init.lua;?.lua;"..package.path
|
|
||||||
local multi = require("multi")
|
local multi = require("multi")
|
||||||
conn = multi:newConnector()
|
conn = multi:newConnector()
|
||||||
conn.OnTest = multi:newConnection()
|
conn.OnTest = multi:newConnection()
|
||||||
@ -1236,7 +1221,6 @@ Going forward:
|
|||||||
Example
|
Example
|
||||||
---
|
---
|
||||||
```lua
|
```lua
|
||||||
package.path="?/init.lua;?.lua;"..package.path
|
|
||||||
multi = require("multi")
|
multi = require("multi")
|
||||||
GLOBAL, THREAD = require("multi.integration.lanesManager").init()
|
GLOBAL, THREAD = require("multi.integration.lanesManager").init()
|
||||||
jq = multi:newSystemThreadedJobQueue()
|
jq = multi:newSystemThreadedJobQueue()
|
||||||
@ -1333,7 +1317,6 @@ Changed:
|
|||||||
- event objects now contain a copy of what returns were made by the function that called it in a table called returns that exist inside of the object
|
- event objects now contain a copy of what returns were made by the function that called it in a table called returns that exist inside of the object
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
package.path="?/init.lua;?.lua;"..package.path
|
|
||||||
multi = require("multi")
|
multi = require("multi")
|
||||||
local a = 0
|
local a = 0
|
||||||
multi:newThread("test",function()
|
multi:newThread("test",function()
|
||||||
@ -1430,7 +1413,6 @@ Now there is a little trick you can do. If you combine both networkmanager and s
|
|||||||
|
|
||||||
**NodeManager.lua**
|
**NodeManager.lua**
|
||||||
```lua
|
```lua
|
||||||
package.path="?/init.lua;?.lua;"..package.path
|
|
||||||
multi = require("multi")
|
multi = require("multi")
|
||||||
local GLOBAL, THREAD = require("multi.integration.lanesManager").init()
|
local GLOBAL, THREAD = require("multi.integration.lanesManager").init()
|
||||||
nGLOBAL = require("multi.integration.networkManager").init()
|
nGLOBAL = require("multi.integration.networkManager").init()
|
||||||
@ -1449,7 +1431,6 @@ Side note: I had a setting called cross talk that would allow nodes to talk to e
|
|||||||
|
|
||||||
**Node.lua**
|
**Node.lua**
|
||||||
```lua
|
```lua
|
||||||
package.path="?/init.lua;?.lua;"..package.path
|
|
||||||
multi = require("multi")
|
multi = require("multi")
|
||||||
local GLOBAL, THREAD = require("multi.integration.lanesManager").init()
|
local GLOBAL, THREAD = require("multi.integration.lanesManager").init()
|
||||||
nGLOBAL = require("multi.integration.networkManager").init()
|
nGLOBAL = require("multi.integration.networkManager").init()
|
||||||
@ -1471,10 +1452,8 @@ multi:mainloop(settings)
|
|||||||
|
|
||||||
**Master.lua**
|
**Master.lua**
|
||||||
```lua
|
```lua
|
||||||
-- set up the package
|
|
||||||
package.path="?/init.lua;?.lua;"..package.path
|
|
||||||
-- Import the libraries
|
-- Import the libraries
|
||||||
multi = require("multi")
|
local multi = require("multi")
|
||||||
local GLOBAL, THREAD = require("multi.integration.lanesManager").init()
|
local GLOBAL, THREAD = require("multi.integration.lanesManager").init()
|
||||||
nGLOBAL = require("multi.integration.networkManager").init()
|
nGLOBAL = require("multi.integration.networkManager").init()
|
||||||
-- Act as a master node
|
-- Act as a master node
|
||||||
@ -1644,7 +1623,6 @@ Added:
|
|||||||
|
|
||||||
Example of threaded connections
|
Example of threaded connections
|
||||||
```lua
|
```lua
|
||||||
package.path="?/init.lua;?.lua;"..package.path
|
|
||||||
local GLOBAL,THREAD=require("multi.integration.lanesManager").init()
|
local GLOBAL,THREAD=require("multi.integration.lanesManager").init()
|
||||||
multi:newSystemThread("Test_Thread_1",function()
|
multi:newSystemThread("Test_Thread_1",function()
|
||||||
connOut = THREAD.waitFor("ConnectionNAMEHERE"):init()
|
connOut = THREAD.waitFor("ConnectionNAMEHERE"):init()
|
||||||
@ -1681,7 +1659,6 @@ Fixed:
|
|||||||
|
|
||||||
Example of threaded tables
|
Example of threaded tables
|
||||||
```lua
|
```lua
|
||||||
package.path="?/init.lua;?.lua;"..package.path
|
|
||||||
local GLOBAL,sThread=require("multi.integration.lanesManager").init()
|
local GLOBAL,sThread=require("multi.integration.lanesManager").init()
|
||||||
multi:newSystemThread("Test_Thread_1",function()
|
multi:newSystemThread("Test_Thread_1",function()
|
||||||
require("multi")
|
require("multi")
|
||||||
@ -2007,7 +1984,6 @@ Added:</br>
|
|||||||
Using multi:systemThreadedBenchmark()
|
Using multi:systemThreadedBenchmark()
|
||||||
---
|
---
|
||||||
```lua
|
```lua
|
||||||
package.path="?/init.lua;"..package.path
|
|
||||||
local GLOBAL,sThread=require("multi.integration.lanesManager").init()
|
local GLOBAL,sThread=require("multi.integration.lanesManager").init()
|
||||||
multi:systemThreadedBenchmark(3):OnBench(function(self,count)
|
multi:systemThreadedBenchmark(3):OnBench(function(self,count)
|
||||||
print("First Bench: "..count)
|
print("First Bench: "..count)
|
||||||
|
|||||||
@ -60,7 +60,6 @@ function THREAD:newFunction(func,holdme)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function multi:newSystemThread(name, func, ...)
|
function multi:newSystemThread(name, func, ...)
|
||||||
print("Creating a thread")
|
|
||||||
multi.InitSystemThreadErrorHandler()
|
multi.InitSystemThreadErrorHandler()
|
||||||
local rand = math.random(1, 10000000)
|
local rand = math.random(1, 10000000)
|
||||||
local return_linda = lanes.linda()
|
local return_linda = lanes.linda()
|
||||||
@ -102,7 +101,6 @@ function multi:newSystemThread(name, func, ...)
|
|||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
function multi.InitSystemThreadErrorHandler()
|
function multi.InitSystemThreadErrorHandler()
|
||||||
print("Thread Created!")
|
|
||||||
if started == true then
|
if started == true then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -123,7 +121,6 @@ function multi.InitSystemThreadErrorHandler()
|
|||||||
temp.alive = false
|
temp.alive = false
|
||||||
temp.OnDeath:Fire(temp,nil,unpack(({temp.returns:receive(0, "returns")})[2]))
|
temp.OnDeath:Fire(temp,nil,unpack(({temp.returns:receive(0, "returns")})[2]))
|
||||||
GLOBAL["__THREADS__"] = livingThreads
|
GLOBAL["__THREADS__"] = livingThreads
|
||||||
--print(temp.thread:cancel(10,true))
|
|
||||||
table.remove(threads, i)
|
table.remove(threads, i)
|
||||||
elseif status == "running" then
|
elseif status == "running" then
|
||||||
--
|
--
|
||||||
@ -132,7 +129,7 @@ function multi.InitSystemThreadErrorHandler()
|
|||||||
elseif status == "error" then
|
elseif status == "error" then
|
||||||
livingThreads[temp.Id] = {false, temp.Name}
|
livingThreads[temp.Id] = {false, temp.Name}
|
||||||
temp.alive = false
|
temp.alive = false
|
||||||
temp.OnError:Fire(temp,nil,unpack(temp.returns:receive(0,"returns")))
|
temp.OnError:Fire(temp,nil,unpack(temp.returns:receive(0,"returns") or {"Thread Killed!"}))
|
||||||
GLOBAL["__THREADS__"] = livingThreads
|
GLOBAL["__THREADS__"] = livingThreads
|
||||||
table.remove(threads, i)
|
table.remove(threads, i)
|
||||||
elseif status == "cancelled" then
|
elseif status == "cancelled" then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user