Merge pull request #42 from rayaman/15.2.1

15.2.1
This commit is contained in:
Ryan Ward 2022-06-06 19:24:35 -04:00 committed by GitHub
commit e14fa83681
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 162 deletions

View File

@ -1,9 +1,6 @@
# Multi Version: 15.2.0 Upgrade Complete # Multi Version: 15.3.0
**Key Changes** **Key Changes**
- All objects now use connections internally -
- Connections now about 23x faster!
- Updated getTasksDetails() to handle the new method of managing threads and processors
- Made lanes optional, install separately if needed
Found an issue? Please [submit it](https://github.com/rayaman/multi/issues) and someone will look into it! Found an issue? Please [submit it](https://github.com/rayaman/multi/issues) and someone will look into it!

View File

@ -1,8 +1,12 @@
# Changelog # Changelog
Table of contents Table of contents
--- ---
[Update 15.2.1 - Bug fix](#update-1521---bug-fix)</br>
[Update 15.2.0 - Upgrade Complete](#update-1520---upgrade-complete)</br>[Update 15.1.0 - Hold the thread!](#update-1510---hold-the-thread)</br>[Update 15.0.0 - The art of faking it](#update-1500---the-art-of-faking-it)</br>[Update 14.2.0 - Bloatware Removed](#update-1420---bloatware-removed)</br>[Update 14.1.0 - A whole new world of possibilities](#update-1410---a-whole-new-world-of-possibilities)</br>[Update 14.0.0 - Consistency, Additions and Stability](#update-1400---consistency-additions-and-stability)</br>[Update 13.1.0 - Bug fixes and features added](#update-1310---bug-fixes-and-features-added)</br>[Update 13.0.0 - Added some documentation, and some new features too check it out!](#update-1300---added-some-documentation-and-some-new-features-too-check-it-out)</br>[Update 12.2.2 - Time for some more bug fixes!](#update-1222---time-for-some-more-bug-fixes)</br>[Update 12.2.1 - Time for some bug fixes!](#update-1221---time-for-some-bug-fixes)</br>[Update 12.2.0 - The chains of binding](#update-1220---the-chains-of-binding)</br>[Update 12.1.0 - Threads just can't hold on anymore](#update-1210---threads-just-cant-hold-on-anymore)</br>[Update: 12.0.0 - Big update (Lots of additions some changes)](#update-1200---big-update-lots-of-additions-some-changes)</br>[Update: 1.11.1 - Small Clarification on Love](#update-1111---small-clarification-on-love)</br>[Update: 1.11.0](#update-1110)</br>[Update: 1.10.0](#update-1100)</br>[Update: 1.9.2](#update-192)</br>[Update: 1.9.1 - Threads can now argue](#update-191---threads-can-now-argue)</br>[Update: 1.9.0](#update-190)</br>[Update: 1.8.7](#update-187)</br>[Update: 1.8.6](#update-186)</br>[Update: 1.8.5](#update-185)</br>[Update: 1.8.4](#update-184)</br>[Update: 1.8.3 - Mainloop recieves some needed overhauling](#update-183---mainloop-recieves-some-needed-overhauling)</br>[Update: 1.8.2](#update-182)</br>[Update: 1.8.1](#update-181)</br>[Update: 1.7.6](#update-176)</br>[Update: 1.7.5](#update-175)</br>[Update: 1.7.4](#update-174)</br>[Update: 1.7.3](#update-173)</br>[Update: 1.7.2](#update-172)</br>[Update: 1.7.1 - Bug Fixes Only](#update-171---bug-fixes-only)</br>[Update: 1.7.0 - Threading the systems](#update-170---threading-the-systems)</br>[Update: 1.6.0](#update-160)</br>[Update: 1.5.0](#update-150)</br>[Update: 1.4.1 (4/10/2017) - First Public release of the library](#update-141-4102017---first-public-release-of-the-library)</br>[Update: 1.4.0 (3/20/2017)](#update-140-3202017)</br>[Update: 1.3.0 (1/29/2017)](#update-130-1292017)</br>[Update: 1.2.0 (12.31.2016)](#update-120-12312016)</br>[Update: 1.1.0](#update-110)</br>[Update: 1.0.0](#update-100)</br>[Update: 0.6.3](#update-063)</br>[Update: 0.6.2](#update-062)</br>[Update: 0.6.1-6](#update-061-6)</br>[Update: 0.5.1-6](#update-051-6)</br>[Update: 0.4.1](#update-041)</br>[Update: 0.3.0 - The update that started it all](#update-030---the-update-that-started-it-all)</br>[Update: EventManager 2.0.0](#update-eventmanager-200)</br>[Update: EventManager 1.2.0](#update-eventmanager-120)</br>[Update: EventManager 1.1.0](#update-eventmanager-110)</br>[Update: EventManager 1.0.0 - Error checking](#update-eventmanager-100---error-checking)</br>[Version: EventManager 0.0.1 - In The Beginning things were very different](#version-eventmanager-001---in-the-beginning-things-were-very-different) [Update 15.2.0 - Upgrade Complete](#update-1520---upgrade-complete)</br>[Update 15.1.0 - Hold the thread!](#update-1510---hold-the-thread)</br>[Update 15.0.0 - The art of faking it](#update-1500---the-art-of-faking-it)</br>[Update 14.2.0 - Bloatware Removed](#update-1420---bloatware-removed)</br>[Update 14.1.0 - A whole new world of possibilities](#update-1410---a-whole-new-world-of-possibilities)</br>[Update 14.0.0 - Consistency, Additions and Stability](#update-1400---consistency-additions-and-stability)</br>[Update 13.1.0 - Bug fixes and features added](#update-1310---bug-fixes-and-features-added)</br>[Update 13.0.0 - Added some documentation, and some new features too check it out!](#update-1300---added-some-documentation-and-some-new-features-too-check-it-out)</br>[Update 12.2.2 - Time for some more bug fixes!](#update-1222---time-for-some-more-bug-fixes)</br>[Update 12.2.1 - Time for some bug fixes!](#update-1221---time-for-some-bug-fixes)</br>[Update 12.2.0 - The chains of binding](#update-1220---the-chains-of-binding)</br>[Update 12.1.0 - Threads just can't hold on anymore](#update-1210---threads-just-cant-hold-on-anymore)</br>[Update: 12.0.0 - Big update (Lots of additions some changes)](#update-1200---big-update-lots-of-additions-some-changes)</br>[Update: 1.11.1 - Small Clarification on Love](#update-1111---small-clarification-on-love)</br>[Update: 1.11.0](#update-1110)</br>[Update: 1.10.0](#update-1100)</br>[Update: 1.9.2](#update-192)</br>[Update: 1.9.1 - Threads can now argue](#update-191---threads-can-now-argue)</br>[Update: 1.9.0](#update-190)</br>[Update: 1.8.7](#update-187)</br>[Update: 1.8.6](#update-186)</br>[Update: 1.8.5](#update-185)</br>[Update: 1.8.4](#update-184)</br>[Update: 1.8.3 - Mainloop recieves some needed overhauling](#update-183---mainloop-recieves-some-needed-overhauling)</br>[Update: 1.8.2](#update-182)</br>[Update: 1.8.1](#update-181)</br>[Update: 1.7.6](#update-176)</br>[Update: 1.7.5](#update-175)</br>[Update: 1.7.4](#update-174)</br>[Update: 1.7.3](#update-173)</br>[Update: 1.7.2](#update-172)</br>[Update: 1.7.1 - Bug Fixes Only](#update-171---bug-fixes-only)</br>[Update: 1.7.0 - Threading the systems](#update-170---threading-the-systems)</br>[Update: 1.6.0](#update-160)</br>[Update: 1.5.0](#update-150)</br>[Update: 1.4.1 (4/10/2017) - First Public release of the library](#update-141-4102017---first-public-release-of-the-library)</br>[Update: 1.4.0 (3/20/2017)](#update-140-3202017)</br>[Update: 1.3.0 (1/29/2017)](#update-130-1292017)</br>[Update: 1.2.0 (12.31.2016)](#update-120-12312016)</br>[Update: 1.1.0](#update-110)</br>[Update: 1.0.0](#update-100)</br>[Update: 0.6.3](#update-063)</br>[Update: 0.6.2](#update-062)</br>[Update: 0.6.1-6](#update-061-6)</br>[Update: 0.5.1-6](#update-051-6)</br>[Update: 0.4.1](#update-041)</br>[Update: 0.3.0 - The update that started it all](#update-030---the-update-that-started-it-all)</br>[Update: EventManager 2.0.0](#update-eventmanager-200)</br>[Update: EventManager 1.2.0](#update-eventmanager-120)</br>[Update: EventManager 1.1.0](#update-eventmanager-110)</br>[Update: EventManager 1.0.0 - Error checking](#update-eventmanager-100---error-checking)</br>[Version: EventManager 0.0.1 - In The Beginning things were very different](#version-eventmanager-001---in-the-beginning-things-were-very-different)
# Update 15.2.1 - Bug fix
Fixed issue #41
# Update 15.2.0 - Upgrade Complete # Update 15.2.0 - Upgrade Complete
Full Update Showcase Full Update Showcase

View File

@ -1,3 +1,4 @@
print("Dev")
--[[ --[[
MIT License MIT License
@ -1471,6 +1472,7 @@ co_status = {
switch[task](ref,thd) switch[task](ref,thd)
cmds[r1](ref,r2,r3,r4,r5) cmds[r1](ref,r2,r3,r4,r5)
if ret ~= CMD and _ ~= nil then -- The rework makes this necessary if ret ~= CMD and _ ~= nil then -- The rework makes this necessary
print("Hello")
co_status["dead"](thd,ref,task,i,th) co_status["dead"](thd,ref,task,i,th)
end end
r1=nil r2=nil r3=nil r4=nil r5=nil r1=nil r2=nil r3=nil r4=nil r5=nil
@ -1478,6 +1480,7 @@ co_status = {
["normal"] = function(thd,ref) end, ["normal"] = function(thd,ref) end,
["running"] = function(thd,ref) end, ["running"] = function(thd,ref) end,
["dead"] = function(thd,ref,task,i,th) ["dead"] = function(thd,ref,task,i,th)
if ref.__processed then return end
if _ then if _ then
ref.OnDeath:Fire(ret,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16) ref.OnDeath:Fire(ret,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16)
else else
@ -1494,6 +1497,7 @@ co_status = {
end end
end end
_=nil r1=nil r2=nil r3=nil r4=nil r5=nil _=nil r1=nil r2=nil r3=nil r4=nil r5=nil
ref.__processed = true
end, end,
} }
handler = coroutine.wrap(function(self) handler = coroutine.wrap(function(self)

View File

@ -139,19 +139,19 @@ 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") or {"Thread Killed!"})) temp.OnError:Fire(temp,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
livingThreads[temp.Id] = {false, temp.Name} livingThreads[temp.Id] = {false, temp.Name}
temp.alive = false temp.alive = false
temp.OnError:Fire(temp,nil,"thread_cancelled") temp.OnError:Fire(temp,"thread_cancelled")
GLOBAL["__THREADS__"] = livingThreads GLOBAL["__THREADS__"] = livingThreads
table.remove(threads, i) table.remove(threads, i)
elseif status == "killed" then elseif status == "killed" then
livingThreads[temp.Id] = {false, temp.Name} livingThreads[temp.Id] = {false, temp.Name}
temp.alive = false temp.alive = false
temp.OnError:Fire(temp,nil,"thread_killed") temp.OnError:Fire(temp,"thread_killed")
GLOBAL["__THREADS__"] = livingThreads GLOBAL["__THREADS__"] = livingThreads
table.remove(threads, i) table.remove(threads, i)
end end

115
test.lua
View File

@ -1,111 +1,20 @@
package.path = "./?/init.lua;"..package.path package.path = "./?/init.lua;?.lua;lua5.4/share/lua/?/init.lua;lua5.4/share/lua/?.lua;"..package.path
package.cpath = "lua5.4/lib/lua/?/core.dll;"..package.cpath
multi, thread = require("multi"):init{print=true} multi, thread = require("multi"):init{print=true}
GLOBAL, THREAD = require("multi.integration.threading"):init() GLOBAL, THREAD = require("multi.integration.lanesManager"):init()
-- Using a system thread, but both system and local threads support this! test = THREAD:newFunction(function()
-- Don't worry if you don't have lanes or love2d. PesudoThreading will kick in to emulate the threading features if you do not have access to system threading. PNT()
func = THREAD:newFunction(function(count) return 1,2
print("Starting Status test: ",count) end,true)
local a = 0 multi:newThread(function()
while true do
a = a + 1
THREAD.sleep(.1)
-- Push the status from the currently running threaded function to the main thread
THREAD.pushStatus(a,count)
if a == count then break end
end
return "Done"
end)
thread:newThread("test",function()
local ret = func(10)
ret.OnStatus(function(part,whole)
print("Ret1: ",math.ceil((part/whole)*1000)/10 .."%")
end)
print("TEST",func(5).wait())
-- The results from the OnReturn connection is passed by thread.hold
print("Status:",thread.hold(ret.OnReturn))
print("Function Done!")
end).OnError(function(...)
print("Error:",...)
end)
local ret = func(10)
local ret2 = func(15)
local ret3 = func(20)
local s1,s2,s3 = 0,0,0
ret.OnError(function(...)
print("Error:",...)
end)
ret2.OnError(function(...)
print("Error:",...)
end)
ret3.OnError(function(...)
print("Error:",...)
end)
ret.OnStatus(function(part,whole)
s1 = math.ceil((part/whole)*1000)/10
print(s1)
end)
ret2.OnStatus(function(part,whole)
s2 = math.ceil((part/whole)*1000)/10
print(s2)
end)
ret3.OnStatus(function(part,whole)
s3 = math.ceil((part/whole)*1000)/10
print(s3)
end)
loop = multi:newTLoop()
function loop:testing()
print("testing haha")
end
loop:Set(1)
t = loop:OnLoop(function()
print("Looping...")
end):testing()
local proc = multi:newProcessor("Test")
local proc2 = multi:newProcessor("Test2")
local proc3 = proc2:newProcessor("Test3")
proc.Start()
proc2.Start()
proc3.Start()
proc:newThread("TestThread_1",function()
while true do while true do
print("...")
thread.sleep(1) thread.sleep(1)
end end
end) end)
proc:newThread("TestThread_2",function() multi:newAlarm(.1):OnRing(function() os.exit() end)
while true do print(test())
thread.sleep(1) print("Hi!")
end
end)
proc2:newThread("TestThread_3",function()
while true do
thread.sleep(1)
end
end)
thread:newThread(function()
thread.sleep(1)
local tasks = multi:getStats()
for i,v in pairs(tasks) do
print("Process: " ..i.. "\n\tTasks:")
for ii,vv in pairs(v.tasks) do
print("\t\t"..vv:getName())
end
print("\tThreads:")
for ii,vv in pairs(v.threads) do
print("\t\t"..vv:getName())
end
end
thread.sleep(10) -- Wait 10 seconds then kill the process!
os.exit()
end)
multi:mainloop() multi:mainloop()

View File

@ -1,51 +0,0 @@
package.path = "./?.lua;?/init.lua;"..package.path
local multi,thread = require("multi"):init{print=true}
--local GLOBAL,THREAD = require("multi.integration.lanesManager"):init()
-- func = THREAD:newFunction(function(a,b,c)
-- print("Hello Thread!",a,b,c)
-- return 1,2,3
-- end)
-- func2 = THREAD:newFunction(function(a,b,c)
-- print("Hello Thread2!",a,b,c)
-- THREAD.sleep(1)
-- return 10,11,12
-- end)
-- multi:newThread("Test thread",function()
-- handler = func(4,5,6)
-- handler2 = func2(7,8,9)
-- thread.hold(handler.OnReturn + handler2.OnReturn)
-- print("Function Done",handler.getReturns())
-- print("Function Done",handler2.getReturns())
-- end)
-- multi:benchMark(1):OnBench(function(sec,steps)
-- print("Steps:",steps)
-- os.exit()
-- end)
print("Running benchmarks! ",_VERSION)
local sleep_for = 1
local a = 0
local c = 1
local function bench(t,step)
a = a + step
c = c + 1
os.exit()
end
--multi:benchMark(sleep_for,multi.Priority_Idle,"Idle:"):OnBench(bench)
--multi:benchMark(sleep_for,multi.Priority_Very_Low,"Very Low:"):OnBench(bench)
--multi:benchMark(sleep_for,multi.Priority_Low,"Low:"):OnBench()
--multi:benchMark(sleep_for,multi.Priority_Below_Normal,"Below Normal:"):OnBench(bench)
--multi:benchMark(sleep_for,multi.Priority_Normal,"Normal:"):OnBench(bench)
--multi:benchMark(sleep_for,multi.Priority_Above_Normal,"Above Normal:"):OnBench(bench)
--multi:benchMark(sleep_for,multi.Priority_High,"High:"):OnBench(bench)
--multi:benchMark(sleep_for,multi.Priority_Very_High,"Very High:"):OnBench(bench)
multi:benchMark(sleep_for,multi.Priority_Core,"Core:"):OnBench(bench)
multi.OnExit(function()
print("Total: ".. a)
end)
multi:mainloop()