updated files
This commit is contained in:
parent
2a55b044ef
commit
5da0be08af
@ -4,7 +4,7 @@ Table of contents
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
# Update 14.2.0 - Destroy!
|
# Update 14.2.0 - Ending it all!
|
||||||
Full Update Showcase
|
Full Update Showcase
|
||||||
---
|
---
|
||||||
```lua
|
```lua
|
||||||
|
|||||||
@ -964,6 +964,12 @@ function multi:scheduleJob(time,func)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Threading stuff
|
-- Threading stuff
|
||||||
|
local initT = false
|
||||||
|
local threadCount = 0
|
||||||
|
local threadid = 0
|
||||||
|
thread.__threads = {}
|
||||||
|
local threads = thread.__threads
|
||||||
|
local Gref = _G
|
||||||
multi.GlobalVariables={}
|
multi.GlobalVariables={}
|
||||||
local dFunc = function() return true end
|
local dFunc = function() return true end
|
||||||
local dRef = {nil,nil,nil}
|
local dRef = {nil,nil,nil}
|
||||||
@ -971,10 +977,20 @@ thread.requests = {}
|
|||||||
function thread.request(t,cmd,...)
|
function thread.request(t,cmd,...)
|
||||||
thread.requests[t.thread] = {cmd,{...}}
|
thread.requests[t.thread] = {cmd,{...}}
|
||||||
end
|
end
|
||||||
|
function thread.getRunningThread()
|
||||||
|
local t = coroutine.running()
|
||||||
|
if t then
|
||||||
|
for i,v in pairs(threads) do
|
||||||
|
if t==v.thread then
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
function thread._Requests()
|
function thread._Requests()
|
||||||
local t = thread.requests[coroutine.running()]
|
local t = thread.requests[coroutine.running()]
|
||||||
thread.requests[coroutine.running()] = nil
|
|
||||||
if t then
|
if t then
|
||||||
|
thread.requests[coroutine.running()] = nil
|
||||||
local cmd,args = t[1],t[2]
|
local cmd,args = t[1],t[2]
|
||||||
thread[cmd](unpack(args))
|
thread[cmd](unpack(args))
|
||||||
end
|
end
|
||||||
@ -984,6 +1000,7 @@ function thread.exec(func)
|
|||||||
end
|
end
|
||||||
function thread.sleep(n)
|
function thread.sleep(n)
|
||||||
thread._Requests()
|
thread._Requests()
|
||||||
|
thread.getRunningThread().lastSleep = clock()
|
||||||
dRef[1] = "_sleep_"
|
dRef[1] = "_sleep_"
|
||||||
dRef[2] = n or 0
|
dRef[2] = n or 0
|
||||||
return coroutine.yield(dRef)
|
return coroutine.yield(dRef)
|
||||||
@ -1150,17 +1167,6 @@ function thread.testFor(name,_val,sym)
|
|||||||
end)
|
end)
|
||||||
return thread.get(name)
|
return thread.get(name)
|
||||||
end
|
end
|
||||||
function multi.print(...)
|
|
||||||
if multi.defaultSettings.print then
|
|
||||||
print(...)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local initT = false
|
|
||||||
local threadCount = 0
|
|
||||||
local threadid = 0
|
|
||||||
thread.__threads = {}
|
|
||||||
local threads = thread.__threads
|
|
||||||
local Gref = _G
|
|
||||||
function multi:newThread(name,func,...)
|
function multi:newThread(name,func,...)
|
||||||
multi.OnLoad:Fire()
|
multi.OnLoad:Fire()
|
||||||
local func = func or name
|
local func = func or name
|
||||||
@ -1468,6 +1474,8 @@ function multi:newService(func) -- Priority managed threads
|
|||||||
elseif math.abs(n)==2 then
|
elseif math.abs(n)==2 then
|
||||||
ap = math.abs(p-1)*32+1
|
ap = math.abs(p-1)*32+1
|
||||||
task = thread.skip
|
task = thread.skip
|
||||||
|
elseif math.abs(n)==3 then
|
||||||
|
-- This is a time based pirority manager. Things that take long to run get
|
||||||
end
|
end
|
||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
@ -2261,6 +2269,12 @@ else
|
|||||||
thread.__CORES=tonumber(io.popen("nproc --all"):read("*n"))
|
thread.__CORES=tonumber(io.popen("nproc --all"):read("*n"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function multi.print(...)
|
||||||
|
if multi.defaultSettings.print then
|
||||||
|
print(...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
multi.GetType=multi.getType
|
multi.GetType=multi.getType
|
||||||
multi.IsPaused=multi.isPaused
|
multi.IsPaused=multi.isPaused
|
||||||
multi.IsActive=multi.isActive
|
multi.IsActive=multi.isActive
|
||||||
|
|||||||
@ -84,16 +84,17 @@ function multi:newSystemThread(name, func, ...)
|
|||||||
c.priority = THREAD.Priority_Normal
|
c.priority = THREAD.Priority_Normal
|
||||||
local args = {...}
|
local args = {...}
|
||||||
multi:newThread(function()
|
multi:newThread(function()
|
||||||
print("I am here!")
|
|
||||||
c.thread = lanes.gen(table.concat(c.loadString,","),
|
c.thread = lanes.gen(table.concat(c.loadString,","),
|
||||||
{
|
{
|
||||||
globals={
|
globals={ -- Set up some globals
|
||||||
THREAD_NAME=name,
|
THREAD_NAME=name,
|
||||||
THREAD_ID=count,
|
THREAD_ID=count,
|
||||||
THREAD = THREAD,
|
THREAD = THREAD,
|
||||||
GLOBAL = GLOBAL,
|
GLOBAL = GLOBAL,
|
||||||
_Console = __ConsoleLinda
|
_Console = __ConsoleLinda
|
||||||
},priority=c.priority}, func)(unpack(args))
|
},
|
||||||
|
priority=c.priority
|
||||||
|
},func)(unpack(args))
|
||||||
thread.kill()
|
thread.kill()
|
||||||
end)
|
end)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
|
|||||||
18
test.lua
18
test.lua
@ -1,7 +1,19 @@
|
|||||||
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
||||||
multi,thread = require("multi"):init()
|
multi,thread = require("multi"):init()
|
||||||
t = multi:newThread(function()
|
local GLOBAL,THREAD = require("multi.integration.lanesManager"):init()
|
||||||
print("Hello!")
|
func = THREAD:newFunction(function(test)
|
||||||
os.exit()
|
print(test)
|
||||||
|
THREAD.sleep(1)
|
||||||
|
return "Hello World!"
|
||||||
end)
|
end)
|
||||||
|
func("Did it work").connect(function(...)
|
||||||
|
print(...)
|
||||||
|
--os.exit()
|
||||||
|
end)
|
||||||
|
local serv = multi:newService(function(self,data)
|
||||||
|
local name = thread.getRunningThread().Name
|
||||||
|
print(name)
|
||||||
|
end)
|
||||||
|
serv.Start()
|
||||||
|
serv.SetPriority(multi.Priority_Low)
|
||||||
multi:lightloop()
|
multi:lightloop()
|
||||||
Loading…
x
Reference in New Issue
Block a user