proccesses are working now!

This commit is contained in:
Luke Miller
2021-05-06 01:05:57 -04:00
parent fb0bb4f049
commit a7ba7605d3
5 changed files with 36 additions and 25 deletions

View File

@@ -7,11 +7,15 @@ modpol.orgs.request_params = {
-- ================================
-- creates a new process linked to a request id
function modpol.orgs:create_process(request_id)
local new_process = {
object = "I am a process",
request_id = request_id
}
function modpol.orgs:create_process(process_type, request_id)
if not modpol.modules[process_type] then
modpol.ocutil.log('Process type "' .. process_type .. '" does not exist')
return
end
-- retrieving requested module
local module = modpol.modules[process_type]
local new_process = module:new_process(request_id, self.id)
-- linear search for empty process slots (lazy deletion)
for k, v in ipairs(self.processes) do
@@ -24,8 +28,10 @@ function modpol.orgs:create_process(request_id)
-- attempts to fill empty spots in list, otherwise appends to end
if empty_index then
self.processes[empty_index] = new_process
return empty_index
else
table.insert(self.processes, new_process)
return #self.processes
end
end