Comparison

util/queue.lua @ 12975:d10957394a3c

util: Prefix module imports with prosody namespace
author Kim Alvefur <zash@zash.se>
date Fri, 17 Mar 2023 16:23:16 +0100
parent 11114:6a608ecb3471
comparison
equal deleted inserted replaced
12974:ba409c67353b 12975:d10957394a3c
7 -- 7 --
8 8
9 -- Small ringbuffer library (i.e. an efficient FIFO queue with a size limit) 9 -- Small ringbuffer library (i.e. an efficient FIFO queue with a size limit)
10 -- (because unbounded dynamically-growing queues are a bad thing...) 10 -- (because unbounded dynamically-growing queues are a bad thing...)
11 11
12 local have_utable, utable = pcall(require, "util.table"); -- For pre-allocation of table 12 local have_utable, utable = pcall(require, "prosody.util.table"); -- For pre-allocation of table
13 13
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