Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
etlng::impl::TaskQueue Class Reference

A wrapper for std::priority_queue that serialises operations using a mutex. More...

#include <TaskQueue.hpp>

Classes

struct  Settings
 

Public Member Functions

 TaskQueue (Settings settings)
 Construct a new priority queue.
 
bool enqueue (model::LedgerData item)
 Enqueue a new item onto the queue if space is available.
 
std::optional< model::LedgerDatadequeue ()
 Dequeue the next available item out of the queue.
 
bool empty ()
 Check if the queue is empty.
 
void awaitTask ()
 Awaits for the queue to become non-empty.
 
void stop ()
 Notify the queue that it's no longer needed.
 

Detailed Description

A wrapper for std::priority_queue that serialises operations using a mutex.

Note
This may be a candidate for future improvements if performance proves to be poor (e.g. use a lock free queue)

Constructor & Destructor Documentation

◆ TaskQueue()

etlng::impl::TaskQueue::TaskQueue ( Settings settings)
inlineexplicit

Construct a new priority queue.

Parameters
settingsSettings for the queue, including starting sequence, increment value, and optional limit
Note
If limit is not set, the queue will have no limit

Member Function Documentation

◆ awaitTask()

void etlng::impl::TaskQueue::awaitTask ( )
inline

Awaits for the queue to become non-empty.

Note
This function blocks until there is a task or the queue is being destroyed

◆ dequeue()

std::optional< model::LedgerData > etlng::impl::TaskQueue::dequeue ( )
inlinenodiscard

Dequeue the next available item out of the queue.

Note
This function blocks until the item is taken off the queue
Returns
An item if available; nullopt otherwise

◆ empty()

bool etlng::impl::TaskQueue::empty ( )
inlinenodiscard

Check if the queue is empty.

Note
This function blocks until the queue is checked
Returns
true if the queue is empty; false otherwise

◆ enqueue()

bool etlng::impl::TaskQueue::enqueue ( model::LedgerData item)
inlinenodiscard

Enqueue a new item onto the queue if space is available.

Note
This function blocks until the item is attempted to be added to the queue
Parameters
itemThe item to add
Returns
true if item added to the queue; false otherwise

◆ stop()

void etlng::impl::TaskQueue::stop ( )
inline

Notify the queue that it's no longer needed.

Note
This must be called before the queue is destroyed

The documentation for this class was generated from the following file: