Fixed some issues and worked on some stuff
This commit is contained in:
parent
f5b9f093d6
commit
3a2bb0c737
53
changes.md
53
changes.md
@ -11,13 +11,13 @@ Full Update Showcase
|
|||||||
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
||||||
local multi,thread = require("multi"):init()
|
local multi,thread = require("multi"):init()
|
||||||
|
|
||||||
|
-- Testing job stuff
|
||||||
function pushJobs()
|
function pushJobs()
|
||||||
multi.Jobs:newJob(function()
|
multi.Jobs:newJob(function()
|
||||||
print("job called")
|
print("job called")
|
||||||
end) -- No name job
|
end) -- No name job
|
||||||
multi.Jobs:newJob(function()
|
multi.Jobs:newJob(function()
|
||||||
print("job called2")
|
print("job called2")
|
||||||
os.exit() -- This is the last thing callec. I link to end the loop when doing examples
|
|
||||||
end,"test")
|
end,"test")
|
||||||
multi.Jobs:newJob(function()
|
multi.Jobs:newJob(function()
|
||||||
print("job called3")
|
print("job called3")
|
||||||
@ -31,21 +31,68 @@ jobsn[1]:removeJob() -- Select a job and remove it
|
|||||||
multi.Jobs:removeJobs("test2") -- Remove all jobs names 'test2'
|
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.SetScheme(1) -- Jobs are internally a service, so setting scheme and priority
|
||||||
multi.Jobs.SetPriority(multi.Priority_Core)
|
multi.Jobs.SetPriority(multi.Priority_Core)
|
||||||
|
-- Testing destroying and fixed connections
|
||||||
|
c = multi:newConnection()
|
||||||
|
c1 = c(function()
|
||||||
|
print("called 1")
|
||||||
|
end)
|
||||||
|
c2 = c(function()
|
||||||
|
print("called 2")
|
||||||
|
end)
|
||||||
|
c3 = c(function()
|
||||||
|
print("called 3")
|
||||||
|
end)
|
||||||
|
print(c1,c2.Type,c3)
|
||||||
|
c:Fire()
|
||||||
|
c2:Destroy()
|
||||||
|
print(c1,c2.Type,c3)
|
||||||
|
c:Fire()
|
||||||
|
c1:Destroy()
|
||||||
|
print(c1,c2.Type,c3)
|
||||||
|
c:Fire()
|
||||||
|
|
||||||
|
-- Destroying alarms and threads
|
||||||
|
local test = multi:newThread(function()
|
||||||
|
while true do
|
||||||
|
thread.sleep(1)
|
||||||
|
print("Hello!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
test.OnDeath(function()
|
||||||
|
os.exit() -- This is the last thing callec. I link to end the loop when doing examples
|
||||||
|
end)
|
||||||
|
local alarm = multi:newAlarm(4):OnRing(function(a)
|
||||||
|
print(a.Type)
|
||||||
|
a:Destroy()
|
||||||
|
print(a.Type)
|
||||||
|
test:Destroy()
|
||||||
|
end)
|
||||||
multi:lightloop()
|
multi:lightloop()
|
||||||
```
|
```
|
||||||
Going Forward:
|
Going Forward:
|
||||||
---
|
---
|
||||||
-
|
-
|
||||||
|
|
||||||
Added:
|
Added:
|
||||||
---
|
---
|
||||||
- Type: destroyed
|
- 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.
|
- 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.
|
||||||
|
|
||||||
|
Fixed:
|
||||||
|
---
|
||||||
|
- Issue with connections not returning a handler for managing a specified conn object.
|
||||||
|
|
||||||
Changed:
|
Changed:
|
||||||
---
|
---
|
||||||
|
- Destroying an object converts the object into a 'destroyed' type.
|
||||||
|
- connections now have type 'connector_link'
|
||||||
|
```lua
|
||||||
|
OnExample = multi:newConnection()
|
||||||
|
conn = OnExample(...)
|
||||||
|
print(conn.Type) -- connector_link
|
||||||
|
```
|
||||||
- Revamped the job system
|
- Revamped the job system
|
||||||
- multi.Jobs:newJob()
|
- multi.Jobs:newJob() — See Full Update Showcase
|
||||||
|
|
||||||
Removed:
|
Removed:
|
||||||
---
|
---
|
||||||
|
|||||||
@ -46,6 +46,7 @@ multi.clock = os.clock
|
|||||||
multi.time = os.time
|
multi.time = os.time
|
||||||
multi.LinkedPath = multi
|
multi.LinkedPath = multi
|
||||||
multi.lastTime = clock()
|
multi.lastTime = clock()
|
||||||
|
|
||||||
multi.Priority_Core = 1
|
multi.Priority_Core = 1
|
||||||
multi.Priority_Very_High = 4
|
multi.Priority_Very_High = 4
|
||||||
multi.Priority_High = 16
|
multi.Priority_High = 16
|
||||||
@ -443,34 +444,34 @@ function multi:newConnection(protect,func,kill)
|
|||||||
local temp = {
|
local temp = {
|
||||||
Link=self.func,
|
Link=self.func,
|
||||||
func=func,
|
func=func,
|
||||||
|
Type="connector_link",
|
||||||
ID=self.ID,
|
ID=self.ID,
|
||||||
Parent=self,
|
Parent=self,
|
||||||
Fire=function(self,...)
|
|
||||||
if self.Parent.lock then return end
|
|
||||||
if self.Parent.protect then
|
|
||||||
local t=pcall(self.func,...)
|
|
||||||
if t then
|
|
||||||
return t
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return self.func(...)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
Remove=function(self)
|
|
||||||
for i=1,#self.Link do
|
|
||||||
if self.Link[i][2]~=nil then
|
|
||||||
if self.Link[i][2]==self.ID then
|
|
||||||
table.remove(self.Link,i)
|
|
||||||
self.remove=function() end
|
|
||||||
self.Link=nil
|
|
||||||
self.ID=nil
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
temp.Destroy=temp.Remove
|
function temp:Fire(...)
|
||||||
|
if self.Parent.lock then return end
|
||||||
|
if self.Parent.protect then
|
||||||
|
local t=pcall(self.func,...)
|
||||||
|
if t then
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return self.func(...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function temp:Destroy()
|
||||||
|
for i=1,#self.Link do
|
||||||
|
if self.Link[i][2]~=nil then
|
||||||
|
if self.Link[i][2]==self.ID then
|
||||||
|
table.remove(self.Link,i)
|
||||||
|
self.remove=function() end
|
||||||
|
self.Link=nil
|
||||||
|
self.ID=nil
|
||||||
|
multi.setType(temp,multi.DestroyedObj)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
if name then
|
if name then
|
||||||
self.connections[name]=temp
|
self.connections[name]=temp
|
||||||
end
|
end
|
||||||
@ -494,8 +495,9 @@ function multi:newConnection(protect,func,kill)
|
|||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
else
|
else
|
||||||
conn_helper(self,tab[1],tab[2],tab[3])
|
return conn_helper(self,tab[1],tab[2],tab[3])
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
c.Connect=c.connect
|
c.Connect=c.connect
|
||||||
c.GetConnection=c.getConnection
|
c.GetConnection=c.getConnection
|
||||||
|
|||||||
37
test.lua
37
test.lua
@ -1,40 +1,5 @@
|
|||||||
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
||||||
--local sterilizer = require("multi.integration.sterilization")
|
--local sterilizer = require("multi.integration.sterilization")
|
||||||
local multi,thread = require("multi"):init()
|
local multi,thread = require("multi"):init()
|
||||||
local test = multi:newThread(function()
|
|
||||||
while true do
|
|
||||||
thread.sleep(1)
|
|
||||||
print("Hello!")
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
local alarm = multi:newAlarm(4):OnRing(function(a)
|
|
||||||
print(a.Type)
|
|
||||||
a:Destroy()
|
|
||||||
print(a.Type)
|
|
||||||
test:Destroy()
|
|
||||||
end)
|
|
||||||
multi:lightloop()
|
|
||||||
-- 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)
|
multi:lightloop()
|
||||||
-- 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