Parameter Type Required Description loop EventLoop✔ The EventLoop the Queue belongs to maxsize int✕ The queue max size. (default = 0) obj table✕ The table to turn into a Queue. Creates a new instance of Queue
This is a FIFO Queue (first in, first out). If maxsize is less than or equal to zero, the queue size is infinite.
Queue.size might be an approximated value some times (on purpose for internal reasons). Use Queue.real_size if you want to get the real queue size.
Returns:
Type Description QueueThe Queue object Table structure:
{ loop = loop, -- The EventLoop the Queue belongs to maxsize = maxsize, -- The queue max size waiting_free = {}, -- The sleeping tasks that are waiting for a free spot in the queue waiting_free_append = 0, -- The "waiting_free append pointer" waiting_free_give = 0, -- The "waiting_free give pointer" waiting_item = {}, -- The sleeping tasks that are waiting for an item in the queue waiting_item_append = 0, -- The "waiting_item append pointer" waiting_item_give = 0, -- The "waiting_item give pointer" size = 0, -- The queue approximated size (±1) real_size = 0 -- The queue real size }
Checks if the queue is full or not
Returns:
Type Description booleanWhether the queue is full or not
Checks if the queue is empty or not
Returns:
Type Description booleanWhether the queue is empty or not
Wakes up a Queue:get task that is waiting for an item to be added.
This method should never be called by the user code.
Returns:
Type Description booleanWhether a task was triggered or not
Wakes up a Queue:add task that is waiting for an item to be removed.
This method should never be called by the user code.
Returns:
Type Description booleanWhether a task was triggered or not
Parameter Type Required Description item table✔ The item to add safe boolean✕ Whether to cancel throwing an error if the queue is full (default = false) Adds an item to the queue without blocking.
Returns:
Type Description booleanWhether the item was added or not (if safe is false, this will always be true)
Parameter Type Required Description item table✔ The item to add Returns a task that, when awaited, will try to add the item to the queue, and if it cant, it will block until it can.
Returns:
Type Description TaskThe task.
Parameter Type Required Description safe boolean✕ Whether to cancel throwing an error if the queue is empty (default = false) Gets an item from the queue without blocking.
Returns:
Type Description boolean,tablefalseif the queue is empty andsafeisfalse, the item (table) otherwise.
Returns a task that, when awaited, will try to get an item from the queue, and if it cant, it will block until it can.
The task always returns atable, which is the item.Returns:
Type Description TaskThe task
Parameter Type Required Description loop EventLoop✔ The EventLoop the Queue belongs to maxsize int✕ The queue max size. (default = 0) obj table✕ The table to turn into a Queue. Creates a new instance of LifoQueue (which inherits from Queue)
This is a LIFO Queue (last in, first out). If maxsize is less than or equal to zero, the queue size is infinite.
Queue.size might be an approximated value some times (on purpose for internal reasons). Use Queue.real_size if you want to get the real queue size.
Returns:
Type Description QueueThe Queue object Table structure:
{ loop = loop, -- The EventLoop the Queue belongs to maxsize = maxsize, -- The queue max size waiting_free = {}, -- The sleeping tasks that are waiting for a free spot in the queue waiting_free_append = 0, -- The "waiting_free append pointer" waiting_free_give = 0, -- The "waiting_free give pointer" waiting_item = {}, -- The sleeping tasks that are waiting for an item in the queue waiting_item_append = 0, -- The "waiting_item append pointer" waiting_item_give = 0, -- The "waiting_item give pointer" size = 0, -- The queue approximated size (±1) real_size = 0 -- The queue real size }
Parameter Type Required Description item QueueItem✔ The item to add safe boolean✕ Whether to cancel throwing an error if the queue is full (default = false) Adds an item to the queue without blocking.
Returns:
Type Description booleanWhether the item was added or not (if safe is false, this will always be true)
Parameter Type Required Description item QueueItem✔ The item to add Returns a task that, when awaited, will try to add the item to the queue, and if it cant, it will block until then.
Returns:
Type Description TaskThe task.
