mirror of
https://github.com/rayaman/multi.git
synced 2026-09-05 07:27:35 -04:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d239c65ea | ||
|
|
fd8e77555a | ||
|
|
b60aab9602 | ||
|
|
180176e2cf | ||
|
|
952b592b97 | ||
|
|
b597fbdf9b | ||
|
|
8fbaa76fe9 | ||
|
|
abb3da416f | ||
|
|
8ba489dc58 |
Vendored
-50
@@ -1,50 +0,0 @@
|
|||||||
{
|
|
||||||
// Use IntelliSense to learn about possible attributes.
|
|
||||||
// Hover to view descriptions of existing attributes.
|
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "launch-lua",
|
|
||||||
"type": "lua",
|
|
||||||
"request": "launch",
|
|
||||||
"workingDirectory": "${workspaceRoot}",
|
|
||||||
"sourceBasePath": "${workspaceRoot}",
|
|
||||||
"executable": "C:\\Program Files (x86)\\Lua\\5.1\\lua.exe",
|
|
||||||
"arguments": "main.lua",
|
|
||||||
"listenPublicly": false,
|
|
||||||
"listenPort": 56789,
|
|
||||||
"encoding": "UTF-8",
|
|
||||||
"env": {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "launch-gideros",
|
|
||||||
"type": "lua",
|
|
||||||
"request": "launch",
|
|
||||||
"workingDirectory": "${workspaceRoot}",
|
|
||||||
"giderosPath": "C:/Program Files (x86)/Gideros",
|
|
||||||
"gprojPath": "${workspaceRoot}/GPROJ.gproj",
|
|
||||||
"jumpToGiderosErrorPosition": false,
|
|
||||||
"stopGiderosWhenDebuggerStops": true,
|
|
||||||
"listenPublicly": false,
|
|
||||||
"listenPort": 56789,
|
|
||||||
"encoding": "UTF-8"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "wait",
|
|
||||||
"type": "lua",
|
|
||||||
"request": "attach",
|
|
||||||
"workingDirectory": "${workspaceRoot}",
|
|
||||||
"sourceBasePath": "${workspaceRoot}",
|
|
||||||
"listenPublicly": false,
|
|
||||||
"listenPort": 56789,
|
|
||||||
"encoding": "UTF-8"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "lua",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "Launch",
|
|
||||||
"program": "${workspaceFolder}/test.lua"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2020 Ryan Ward
|
Copyright (c) 2021 Ryan Ward
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ My multitasking library for lua. It is a pure lua binding, with exceptions of th
|
|||||||
|
|
||||||
INSTALLING
|
INSTALLING
|
||||||
----------
|
----------
|
||||||
Links to dependicies:
|
Links to dependencies:
|
||||||
[lanes](https://github.com/LuaLanes/lanes)
|
[lanes](https://github.com/LuaLanes/lanes)
|
||||||
|
|
||||||
To install copy the multi folder into your environment and you are good to go</br>
|
To install copy the multi folder into your environment and you are good to go</br>
|
||||||
@@ -25,6 +25,7 @@ Planned features/TODO
|
|||||||
---------------------
|
---------------------
|
||||||
- [x] ~~Finish Documentation~~ Finished
|
- [x] ~~Finish Documentation~~ Finished
|
||||||
- [ ] Network Parallelism rework
|
- [ ] Network Parallelism rework
|
||||||
|
- [ ] Fix some bugs
|
||||||
|
|
||||||
Usage: [Check out the documentation for more info](https://github.com/rayaman/multi/blob/master/Documentation.md)</br>
|
Usage: [Check out the documentation for more info](https://github.com/rayaman/multi/blob/master/Documentation.md)</br>
|
||||||
-----
|
-----
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
-- set up the package
|
|
||||||
package.path="?/init.lua;?.lua;"..package.path
|
|
||||||
-- Import the libraries
|
|
||||||
multi = require("multi")
|
|
||||||
local GLOBAL, THREAD = require("multi.integration.lanesManager").init()
|
|
||||||
nGLOBAL = require("multi.integration.networkManager").init()
|
|
||||||
-- Act as a master node
|
|
||||||
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
|
|
||||||
--managerDetails = {"localhost",12345}, -- the details to connect to the node manager (ip,port)
|
|
||||||
}
|
|
||||||
master.OnError(function(name,err)
|
|
||||||
print(name.." has encountered an error: "..err)
|
|
||||||
end)
|
|
||||||
master.OnNodeConnected(function(name)
|
|
||||||
-- name is the name of the node that connected
|
|
||||||
end)
|
|
||||||
-- Starting the multitasker
|
|
||||||
settings = {
|
|
||||||
priority = 0, -- 0, 1 or 2
|
|
||||||
protect = false,
|
|
||||||
}
|
|
||||||
multi:threadloop(settings) -- both mainloop and threadloop can be used. one pirotizes threads where the other pirotizes multiobjs
|
|
||||||
--multi:mainloop(settings)
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package.path="?/init.lua;?.lua;"..package.path
|
|
||||||
multi = require("multi")
|
|
||||||
local GLOBAL, THREAD = require("multi.integration.lanesManager").init()
|
|
||||||
nGLOBAL = require("multi.integration.networkManager").init()
|
|
||||||
node = multi:newNode{
|
|
||||||
allowRemoteRegistering = true, -- allows you to register functions from the master on the node, default is false
|
|
||||||
name = nil, -- default value
|
|
||||||
--noBroadCast = true, -- if using the node manager, set this to true to prevent the node from broadcasting
|
|
||||||
--managerDetails = {"localhost",12345}, -- connects to the node manager if one exists
|
|
||||||
}
|
|
||||||
settings = {
|
|
||||||
priority = 0, -- 1 or 2
|
|
||||||
stopOnError = true, -- if an actor crashes this will prevent it from constantly crashing over and over. You can leave this false and use multi.OnError to handle crashes as well
|
|
||||||
protect = true, -- always protect a node. Not really needed since all executed xode from a master is protected on execution to prevent issues.
|
|
||||||
}
|
|
||||||
multi:mainloop(settings)
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package.path="?/init.lua;?.lua;"..package.path
|
|
||||||
multi = require("multi")
|
|
||||||
local GLOBAL, THREAD = require("multi.integration.lanesManager").init()
|
|
||||||
nGLOBAL = require("multi.integration.networkManager").init()
|
|
||||||
multi:nodeManager(12345) -- Host a node manager on port: 12345
|
|
||||||
print("Node Manager Running...")
|
|
||||||
settings = {
|
|
||||||
priority = 0, -- 1 or 2
|
|
||||||
protect = false,
|
|
||||||
}
|
|
||||||
multi:mainloop(settings)
|
|
||||||
-- Thats all you need to run the node manager, everything else is done automatically
|
|
||||||
@@ -1,44 +1,17 @@
|
|||||||
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()
|
||||||
|
local GLOBAL, THREAD = require("multi.integration.lanesManager"):init()
|
||||||
-- Testing destroying and fixed connections
|
multi:newSystemThread("test",function(msg)
|
||||||
c = multi:newConnection()
|
print("In thread:", THREAD.getID(), "Msg:", msg)
|
||||||
c1 = c(function()
|
while true do
|
||||||
print("called 1")
|
-- Hold forever :D
|
||||||
end)
|
end
|
||||||
c2 = c(function()
|
end,"Passing a message")
|
||||||
print("called 2")
|
multi:newThread("localthread",function()
|
||||||
end)
|
print("In local thread :D")
|
||||||
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
|
while true do
|
||||||
thread.sleep(1)
|
thread.sleep(1)
|
||||||
print("Hello!")
|
print("...")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
multi:mainloop()
|
||||||
test.OnDeath(function()
|
|
||||||
os.exit() -- This is the last thing called.
|
|
||||||
end)
|
|
||||||
|
|
||||||
local alarm = multi:newAlarm(4):OnRing(function(a)
|
|
||||||
print(a.Type)
|
|
||||||
a:Destroy()
|
|
||||||
print(a.Type)
|
|
||||||
test:Destroy()
|
|
||||||
end)
|
|
||||||
|
|
||||||
multi:lightloop()
|
|
||||||
Reference in New Issue
Block a user