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.
 

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
limitThe limit of items allowed simultaneously in the queue

Member Function Documentation

◆ 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

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