Software /
code /
prosody
Diff
util/queue.lua @ 10411:db2a06b9ff98
Merge 0.11->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 16 Nov 2019 16:52:31 +0100 |
parent | 9926:1bfd28e774db |
child | 10973:39991e40d1dc |
line wrap: on
line diff
--- a/util/queue.lua Sat Nov 16 16:45:33 2019 +0100 +++ b/util/queue.lua Sat Nov 16 16:52:31 2019 +0100 @@ -52,18 +52,20 @@ return t[tail]; 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