Added a blackhole object
This commit is contained in:
parent
f737516009
commit
87467afd17
32
changes.md
32
changes.md
@ -8,19 +8,43 @@ Table of contents
|
||||
Full Update Showcase
|
||||
---
|
||||
```lua
|
||||
package.path="?.lua;?/init.lua;?.lua;"..package.path
|
||||
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
||||
local multi,thread = require("multi"):init()
|
||||
GLOBAL,THREAD = require("multi.integration.lanesManager"):init()
|
||||
|
||||
function pushJobs()
|
||||
multi.Jobs:newJob(function()
|
||||
print("job called")
|
||||
end) -- No name job
|
||||
multi.Jobs:newJob(function()
|
||||
print("job called2")
|
||||
os.exit() -- This is the last thing callec. I link to end the loop when doing examples
|
||||
end,"test")
|
||||
multi.Jobs:newJob(function()
|
||||
print("job called3")
|
||||
end,"test2")
|
||||
end
|
||||
pushJobs()
|
||||
pushJobs()
|
||||
local jobs = multi.Jobs:getJobs() -- gets all jobs
|
||||
local jobsn = multi.Jobs:getJobs("test") -- gets all jobs names 'test'
|
||||
jobsn[1]:removeJob() -- Select a job and remove it
|
||||
multi.Jobs:removeJobs("test2") -- Remove all jobs names 'test2'
|
||||
multi.Jobs.SetScheme(1) -- Jobs are internally a service, so setting scheme and priority
|
||||
multi.Jobs.SetPriority(multi.Priority_Core)
|
||||
|
||||
multi:lightloop()
|
||||
```
|
||||
Going Forward:
|
||||
---
|
||||
-
|
||||
Added:
|
||||
---
|
||||
-
|
||||
- Type: destroyed
|
||||
- A special state of an object that causes that object to become immutable and callable. The object Type is always "destroyed" it cannot be changed. The object can be indexed to infinity without issue. Every part of the object can be called as if it were a function including the indexed parts. This is done incase you destroy an object and still use it somewhere. However, if you are expecting something from the object then you may still encounter an error, though the returned type is an instance of the destroyed object which can be indexed and called like normal. This object can be used in any way and no errors will come about with it.
|
||||
Changed:
|
||||
---
|
||||
-
|
||||
- Revamped the job system
|
||||
- multi.Jobs:newJob()
|
||||
Removed:
|
||||
---
|
||||
- multi:newTrigger() — Connections do everything this thing could do and more. I plan on removing bloat features from the library anyway
|
||||
|
||||
@ -46,6 +46,18 @@ multi.clock = os.clock
|
||||
multi.time = os.time
|
||||
multi.LinkedPath = multi
|
||||
multi.lastTime = clock()
|
||||
multi.DestroyedObj = {
|
||||
Type = "destroyed",
|
||||
}
|
||||
local function uni()
|
||||
return multi.DestroyedObj
|
||||
end
|
||||
|
||||
setmetatable(multi.DestroyedObj, {
|
||||
__index = function(t,k)
|
||||
return setmetatable({},{__index = uni,__newindex = uni,__call = uni,__metatable = multi.DestroyedObj,__tostring = function() return "destroyed" end,__unm = uni,__add = uni,__sub = uni,__mul = uni,__div = uni,__mod = uni,__pow = uni,__concat = uni})
|
||||
end,__newindex = uni,__call = uni,__metatable = multi.DestroyedObj,__tostring = function() return "destroyed" end,__unm = uni,__add = uni,__sub = uni,__mul = uni,__div = uni,__mod = uni,__pow = uni,__concat = uni
|
||||
})
|
||||
math.randomseed(os.time())
|
||||
local mainloopActive = false
|
||||
local isRunning = false
|
||||
@ -804,13 +816,6 @@ function multi:newConnection(protect,func,kill)
|
||||
end
|
||||
c.Connect=c.connect
|
||||
c.GetConnection=c.getConnection
|
||||
function c:tofile(path)
|
||||
local m=bin.new()
|
||||
m:addBlock(self.Type)
|
||||
m:addBlock(self.func)
|
||||
m:tofile(path)
|
||||
return self
|
||||
end
|
||||
if not(ignoreconn) then
|
||||
multi:create(c)
|
||||
end
|
||||
@ -916,14 +921,6 @@ function multi:newTimer()
|
||||
time=os.clock()-time
|
||||
return self
|
||||
end
|
||||
function c:tofile(path)
|
||||
local m=bin.new()
|
||||
count=count+self:Get()
|
||||
m:addBlock(self.Type)
|
||||
m:addBlock(count)
|
||||
m:tofile(path)
|
||||
return self
|
||||
end
|
||||
self:create(c)
|
||||
return c
|
||||
end
|
||||
@ -1587,7 +1584,7 @@ function multi:newThread(name,func,...)
|
||||
end
|
||||
c.creationTime = os.clock()
|
||||
threadid = threadid + 1
|
||||
multi.create(multi,c)
|
||||
self:create(c)
|
||||
return c
|
||||
end
|
||||
function multi.initThreads(justThreads)
|
||||
|
||||
42
test.lua
42
test.lua
@ -1,15 +1,31 @@
|
||||
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
||||
local multi,thread = require("multi"):init()
|
||||
--local sterilizer = require("multi.integration.sterilization")
|
||||
multi.Jobs:newJob(function()
|
||||
print("job called")
|
||||
end)
|
||||
multi.Jobs:newJob(function()
|
||||
print("job called2")
|
||||
end)
|
||||
multi.Jobs:newJob(function()
|
||||
print("job called3")
|
||||
end)
|
||||
multi.Jobs.SetScheme(1)
|
||||
multi.Jobs.SetPriority(multi.Priority_Core)
|
||||
multi:lightloop()
|
||||
local multi,thread = require("multi"):init()
|
||||
bin = multi.DestroyedObj
|
||||
local file = bin.new()
|
||||
local data = file:getData()
|
||||
print(data)
|
||||
-- function pushJobs()
|
||||
-- multi.Jobs:newJob(function()
|
||||
-- print("job called")
|
||||
-- end) -- No name job
|
||||
-- multi.Jobs:newJob(function()
|
||||
-- print("job called2")
|
||||
-- os.exit() -- This is the last thing callec. I link to end the loop when doing examples
|
||||
-- end,"test")
|
||||
-- multi.Jobs:newJob(function()
|
||||
-- print("job called3")
|
||||
-- end,"test2")
|
||||
-- end
|
||||
-- pushJobs()
|
||||
-- pushJobs()
|
||||
-- multi:newThread(function()
|
||||
|
||||
-- end)
|
||||
-- local jobs = multi.Jobs:getJobs() -- gets all jobs
|
||||
-- local jobsn = multi.Jobs:getJobs("test") -- gets all jobs names 'test'
|
||||
-- jobsn[1]:removeJob() -- Select a job and remove it
|
||||
-- multi.Jobs:removeJobs("test2") -- Remove all jobs names 'test2'
|
||||
-- multi.Jobs.SetScheme(1) -- Jobs are internally a service, so setting scheme and priority
|
||||
-- multi.Jobs.SetPriority(multi.Priority_Core)
|
||||
-- multi:lightloop()
|
||||
Loading…
x
Reference in New Issue
Block a user