Module jls.util.Queue
Represents a list of data in first-in first-out order.
Class Queue
| queue:enqueue (data) | Adds the specified data to the queue. |
| queue:dequeue () | Removes and returns the first data of the queue. |
| Queue.share (queue) | Returns a queue that is thread safe. |
| Queue.block (queue, timeout) | Returns a queue that blocks until data could be queued. |
| Queue.ringBuffer (buffer) | Returns a queue using a circular buffer. |
Class Queue
The Queue class.
- queue:enqueue (data)
-
Adds the specified data to the queue.
Parameters:
- data string The data to add at the end of the queue
Returns:
-
boolean
true if the data has been added
- queue:dequeue ()
-
Removes and returns the first data of the queue.
Returns:
-
string
The first data or nil if there is nothing in the queue
- Queue.share (queue)
-
Returns a queue that is thread safe.
Parameters:
- queue jls.util.Queue The queue
Returns:
-
jls.util.Queue
the thread safe queue
- Queue.block (queue, timeout)
-
Returns a queue that blocks until data could be queued.
Parameters:
- queue jls.util.Queue The queue
- timeout number The max duration in milliseconds to wait for enqueue
Returns:
-
jls.util.Queue
the blocking queue
- Queue.ringBuffer (buffer)
-
Returns a queue using a circular buffer.
Parameters:
- buffer jls.lang.Buffer The buffer
Returns:
-
jls.util.Queue
the ring buffer