Mercurial > prosody-hg
diff util/queue.lua @ 11200:bf8f2da84007
Merge 0.11->trunk
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 05 Nov 2020 22:31:25 +0100 |
| parents | 6a608ecb3471 |
| children | d10957394a3c |
line wrap: on
line diff
--- a/util/queue.lua Thu Nov 05 22:27:17 2020 +0100 +++ b/util/queue.lua Thu Nov 05 22:31:25 2020 +0100 @@ -59,18 +59,20 @@ return true; end; items = function (self) - --luacheck: ignore 431/t - return function (t, pos) - if pos >= t:count() then + return function (_, pos) + if pos >= items then return nil; end local read_pos = tail + pos; - if read_pos > t.size then + if read_pos > self.size then read_pos = (read_pos%size); end - return pos+1, t._items[read_pos]; + return pos+1, t[read_pos]; end, self, 0; end; + consume = function (self) + return self.pop, self; + end; }; end
