Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: SystemExecutor:ExecTasks, scheduler is nil in while loop #8

Open
kakagamescom opened this issue Oct 18, 2022 · 0 comments
Open

Comments

@kakagamescom
Copy link

kakagamescom commented Oct 18, 2022

When i run task system according to the document. i got scheduler is nil error.

local log = {}
local Task_A = ECS.System('task', function()
   -- In this example, TASK_A takes time to execute, delaying its execution
   local i = 0
   while i <= 4000 do
      i = i + 1
      if i%1000 == 0 then
         coroutine.yield()
      end
   end
   
   table.insert(log, 'A')
end)

local Task_B = ECS.System('task', function()
   table.insert(log, 'B')
end)

local Task_C = ECS.System('task', function()
   table.insert(log, 'C')
end)

local Task_D = ECS.System('task', function()
   table.insert(log, 'D')
end)

local Task_E = ECS.System('task', function()
   table.insert(log, 'E')
end)

local Task_F = ECS.System('task', function()
   table.insert(log, 'F')
end)

local Task_G = ECS.System('task', function()
   table.insert(log, 'G')
end)

local Task_H = ECS.System('task', function(self)
   table.insert(log, 'H')
end)

--[[         
   A<-------C<---+-----F<----+
            |    |     |     |
       +----+    E<----+     H
       |         |           |
   B<--+----D<---+------G<---+

   A - has no dependency
   B - has no dependency
   C - Depends on A,B
   D - Depends on B
   E - Depends on A,B,C,D
   F - Depends on A,B,C,D,E
   G - Depends on B,D
   H - Depends on A,B,C,D,E,F,G

   Completion order will be B,D,G,A,C,E,F,H      

   > In this example, TASK_A takes time to execute, delaying its execution
]]
Task_A.Before = {Task_C}
Task_B.Before = {Task_D}
Task_C.After = {Task_B}
Task_D.Before = {Task_G}
Task_F.After = {Task_E}
Task_E.After = {Task_D, Task_C}
Task_C.Before = {Task_F}
Task_H.After = {Task_F, Task_G}

world:AddSystem(Task_A)
world:AddSystem(Task_B)
world:AddSystem(Task_C)
world:AddSystem(Task_D)
world:AddSystem(Task_E)
world:AddSystem(Task_F)
world:AddSystem(Task_G)
world:AddSystem(Task_H)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant