Mercurial > prosody-hg
comparison util/queue.lua @ 6912:cb5b14c95b7b
util.queue: Add luacheck annotations
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 18 Oct 2015 21:54:17 +0100 |
| parents | 56c9bc4ba247 |
| children | c8b75239846c 73b8aaf55775 |
comparison
equal
deleted
inserted
replaced
| 6911:56c9bc4ba247 | 6912:cb5b14c95b7b |
|---|---|
| 14 local function new(size, allow_wrapping) | 14 local function new(size, allow_wrapping) |
| 15 -- Head is next insert, tail is next read | 15 -- Head is next insert, tail is next read |
| 16 local head, tail = 1, 1; | 16 local head, tail = 1, 1; |
| 17 local items = 0; -- Number of stored items | 17 local items = 0; -- Number of stored items |
| 18 local t = have_utable and utable.create(size, 0) or {}; -- Table to hold items | 18 local t = have_utable and utable.create(size, 0) or {}; -- Table to hold items |
| 19 | 19 --luacheck: ignore 212/self |
| 20 return { | 20 return { |
| 21 _items = t; | 21 _items = t; |
| 22 size = size; | 22 size = size; |
| 23 count = function (self) return items; end; | 23 count = function (self) return items; end; |
| 24 push = function (self, item) | 24 push = function (self, item) |
| 50 return nil; | 50 return nil; |
| 51 end | 51 end |
| 52 return t[tail]; | 52 return t[tail]; |
| 53 end; | 53 end; |
| 54 items = function (self) | 54 items = function (self) |
| 55 --luacheck: ignore 431/t | |
| 55 return function (t, pos) | 56 return function (t, pos) |
| 56 if pos >= t:count() then | 57 if pos >= t:count() then |
| 57 return nil; | 58 return nil; |
| 58 end | 59 end |
| 59 local read_pos = tail + pos; | 60 local read_pos = tail + pos; |
