Comparison

util/async.lua @ 8603:dc5f3302a642

util.async: Bugfix, don't continue main loop while there is a pending error
author Matthew Wild <mwild1@gmail.com>
date Fri, 16 Mar 2018 17:12:36 +0000
parent 8602:9901deadc068
child 8604:1c8c7fd259c8
comparison
equal deleted inserted replaced
8602:9901deadc068 8603:dc5f3302a642
127 127
128 -- Process task item(s) while the queue is not empty, and we're not blocked 128 -- Process task item(s) while the queue is not empty, and we're not blocked
129 local n, state, err = #q, self.state, nil; 129 local n, state, err = #q, self.state, nil;
130 self.state = "running"; 130 self.state = "running";
131 self:log("debug", "running main loop"); 131 self:log("debug", "running main loop");
132 while n > 0 and state == "ready" do 132 while n > 0 and state == "ready" and not err do
133 local consumed; 133 local consumed;
134 -- Loop through queue items, and attempt to run them 134 -- Loop through queue items, and attempt to run them
135 for i = 1,n do 135 for i = 1,n do
136 local queued_input = q[i]; 136 local queued_input = q[i];
137 local ok, new_state = coroutine.resume(thread, queued_input); 137 local ok, new_state = coroutine.resume(thread, queued_input);