v13.0.0 #11

Merged
rayaman merged 20 commits from v13.0.0 into master 2019-03-22 21:21:37 -04:00
5 changed files with 41 additions and 27 deletions
Showing only changes of commit 8f0f404c36 - Show all commits

View File

@ -57,6 +57,7 @@ Fixed:
- Fixed an issue where any argument greater than 256^2/65536 bytes is sent the networkmanager would soft crash. This was fixed by increading the limit to 256^4/4294967296 bytes. The fix was changing a 2 to a 4. Arguments greater than 256^4 would be impossible in 32 bit lua, and highly unlikely even in lua 64 bit. Perhaps someone is reading an entire file into ram and then sending the entire file that they read over a socket for some reason all at once!?
- Fixed an issue with processors not properly destroying objects within them and not being destroyable themselves
- Fixed a bug where pause and resume would duplicate objects! Not good
- Noticed that the switching of lua states, corutine based threading, is slow when done often. Code your threads to have an idler of .5 seconds between sleep states. After doing this to a few built in threads I've seen a nice drop in performance. 68%-100% to 0%-40% when using the jobqueue. If you dont need the hold feature then use a multi object! Sleeping can be done in a multi object using timers and alarms. Though if your aim is speed timers are a bit faster than alarms, if you really want to boost speed then local clock = os.clock and use the clock function to do your timings yourself
Added:
- Documentation, the purpose of 13.0.0, orginally going to be 12.2.3, but due to the amount of bugs and features I added couldn't become that. I actually still did my tests in the 12.2.3 branch in github.

View File

@ -335,7 +335,7 @@ local ProcessName = {[true]="SubProcessor",[false]="MainProcessor"}
function multi:getTasksDetails(t)
if t == "string" or not t then
str = {
{"Type <Identifier","Uptime","Priority","TID"}
{"Type <Identifier>","Uptime","Priority","TID"}
}
local count = 0
for i,v in pairs(self.Mainloop) do
@ -1489,6 +1489,7 @@ multi:setDomainName("Threads")
multi:setDomainName("Globals")
local initT = false
function multi:newThread(name,func)
if not func then return end
local c={}
c.ref={}
c.Name=name

View File

@ -116,7 +116,7 @@ local rand = math.random(1,10000000)
-- Step 5 Basic Threads!
-- local threads = {}
local count = 0
local started
local started = false
function multi:newSystemThread(name,func,...)
multi.InitSystemThreadErrorHandler()
rand = math.random(1,10000000)
@ -152,7 +152,8 @@ function multi:newSystemThread(name,func,...)
return c
end
function multi.InitSystemThreadErrorHandler()
if started then return end
if started==true then return end
started = true
multi:newThread("ThreadErrorHandler",function()
local deadThreads = {}
local threads = multi.SystemThreads

View File

@ -112,6 +112,7 @@ function multi:newSystemThreadedQueue(name) -- in love2d this will spawn a chann
end
return c
end
-- NEEDS WORK
function multi:newSystemThreadedConnection(name,protect)
local c={}
local sThread=multi.integration.THREAD
@ -284,6 +285,7 @@ function multi:newSystemThreadedConsole(name)
GLOBAL[c.name]=c
return c
end
-- NEEDS WORK
function multi:newSystemThreadedTable(name)
local c={}
c.name=name -- set the name this is important for identifying what is what
@ -334,8 +336,9 @@ function multi:newSystemThreadedJobQueue(a,b)
local sThread=multi.integration.THREAD
local c = {}
c.numberofcores = 4
c.idle = nil
c.name = "SYSTEM_THREADED_JOBQUEUE_"..jobqueuecount
-- This is done to keep backwards compatability for older code
-- This is done to keep backwards compatibility for older code
if type(a)=="string" and not(b) then
c.name = a
elseif type(a)=="number" and not (b) then
@ -363,6 +366,7 @@ function multi:newSystemThreadedJobQueue(a,b)
end
c.tempQueue = {}
function c:pushJob(name,...)
c.idle = os.clock()
if not self.isReady then
table.insert(c.tempQueue,{self.jobnum,name,...})
self.jobnum=self.jobnum+1
@ -429,12 +433,9 @@ function multi:newSystemThreadedJobQueue(a,b)
end
end
end)
multi:newThread("Idler",function()
while true do
if os.clock()-lastjob>1 then
sThread.sleep(.1)
end
thread.sleep(.001)
multi:newLoop(function()
if os.clock()-lastjob>1 then
sThread.sleep(.1)
end
end)
setmetatable(_G,{
@ -447,11 +448,12 @@ function multi:newSystemThreadedJobQueue(a,b)
end
end,c.name)
end
multi:newThread("counter",function()
local clock = os.clock
multi:newThread("JQ-"..c.name.." Manager",function()
print("thread started")
local _count = 0
while _count<c.numberofcores do
thread.skip(1)
thread.skip()
if queueCC:pop() then
_count = _count + 1
end
@ -464,11 +466,19 @@ function multi:newSystemThreadedJobQueue(a,b)
c.OnReady:Fire(c)
local dat
while true do
thread.skip(1)
if not c.idle then
thread.sleep(.5)
else
if clock() - c.idle >= 15 then
c.idle = nil
end
end
dat = queueJD:pop()
if dat then
c.idle = clock()
c.OnJobCompleted:Fire(unpack(dat))
end
thread.skip()
end
end)
return c

View File

@ -10,7 +10,7 @@ function sleep(n) -- seconds
end
master = multi:newMaster{
name = "Main", -- the name of the master
--~ --noBroadCast = true, -- if using the node manager, set this to true to avoid double connections
noBroadCast = true, -- if using the node manager, set this to true to avoid double connections
managerDetails = {"192.168.1.4",12345}, -- the details to connect to the node manager (ip,port)
}
master.OnError(function(name,err)
@ -28,20 +28,21 @@ end)
master.OnNodeConnected(function(name)
table.insert(connlist,name)
end)
--~ multi:newThread("TaskView",function()
--~ while true do
--~ thread.sleep(1)
--~ print(multi:getTasksDetails())
--~ end
--~ end)
multi:newSystemThread("SystemThread",function()
local multi = require("multi")
print(THREAD.getName(),THREAD.getID())
THREAD.sleep(8)
end).OnError(function(a,b,c)
print("ERROR:",b)
multi.OnError(function(...)
print(...)
end)
--~ print(multi:getTasksDetails())
multi:newSystemThreadedConsole("console"):init()
jQueue = multi:newSystemThreadedJobQueue("MainJobQueue")
jQueue.OnReady:holdUT()
jQueue:doToAll(function()
console = THREAD.waitFor("console"):init()
end)
jQueue:registerJob("TEST",function(a,b,c)
console:print(a,b,c)
return "This is a test"
end)
jQueue:pushJob("TEST",123,"Hello",false)
--~ multi:benchMark(1,nil,"Bench:")
multi:mainloop{
protect = false
}