Class: SharedQueue
@include <SharedQueue>
The SharedQueue class provides a queue implementation that shares its state across multiple instances. This class is useful for scenarios in which we’re forking processes and need a shared queue between them.
Reads and writes are atomic and concurrency-safe.
The queue can be encrypted for security.
Internally, it uses the file system to store the queue state.
Methods
@SharedQueue.setEncrypted
Scope: public
Sets whether the queue should be encrypted. Encrypting the queue can mitigate unauthorized reads by other processes. This cannot be changed after the queue has been used.
Usage: @SharedQueue.setEncrypted $value
Parameters
value
- Type:
primitive
- ‘1’ or ‘true’ enables encryption, any other value disables it.
- Type:
@SharedQueue.size
Scope: public
Echoes the number of elements in the queue.
Usage: @SharedQueue.size
@SharedQueue.enqueue
Scope: public
Adds a value to the back of the queue.
Usage: @SharedQueue.enqueue $value
Parameters
value
- Type:
primitive
- The value to add to the queue.
- Type:
@SharedQueue.dequeue
Scope: public
Removes the front element from the queue and echoes it.
Usage: @SharedQueue.dequeue
@SharedQueue.front
Scope: public
Echoes the front element of the queue without removing it.
Usage: @SharedQueue.front
@SharedQueue.back
Scope: public
Echoes the back element of the queue without removing it.
Usage: @SharedQueue.back
@SharedQueue.clear
Scope: public
Removes all elements from the queue.
Usage: @SharedQueue.clear
@SharedQueue.empty
Scope: public
Echoes “true” if the queue is empty, “false” otherwise.
Usage: @SharedQueue.empty