Pillarbox
public class Pillarbox<Element> where Element : Decodable, Element : Encodable
A object-based queue which is persisted to the disk. Supports both FIFO and LIFO strategies. Should be thread-safe as well.
-
Initializes and returns a newly allocated Pillarbox.
Declaration
Swift
@inlinable public init( name: String, url: URL, configuration: PillarboxConfiguration = PillarboxConfiguration() )
Parameters
name
The name of the queue file
url
The url of the directory to create the queue file in
configuration
The Pillarbox configuration
-
Retrieves, but does not remove, the head of the queue, or returns
nil
f the queue is empty. If the strategy isfifo
, the first inserted item will be returned, forlifo
it will be the last one.Declaration
Swift
@inlinable func peek() -> Element?
Return Value
The retrieved element or
nil
-
Retrieves and removes the head of the queue, or returns
nil
if the queue is empty. Writes the updated queue to the disk and removes the persisted element. If the strategy isfifo
, the first inserted item will be returned, forlifo
it will be the last one.Declaration
Swift
@discardableResult @inlinable func pop() -> Element?
Return Value
The retrieved element or
nil
-
Pushes the specified element into the queue and persist it on the disk.
Declaration
Swift
@discardableResult @inlinable func push(_ element: Element) -> String
Parameters
element
The element to push into the queue.
Return Value
The key which identifies the element
-
A Boolean value indicating whether the queue is empty.
Declaration
Swift
@inlinable var isEmpty: Bool { get }
-
The number of elements in the queue.
Declaration
Swift
@inlinable var count: Int { get }
-
All elements in the queue
Declaration
Swift
@inlinable var elements: [Element] { get }
-
Undocumented
Declaration
Swift
@inlinable subscript(key: String) -> Element? { get }