bmv2
Designing your own switch target with bmv2
Public Member Functions | List of all members
bm::QueueingLogicPriRL< T, FMap > Class Template Reference

Public Member Functions

 QueueingLogicPriRL (size_t nb_workers, size_t capacity, FMap map_to_worker, size_t nb_priorities=2)
 
int push_front (size_t queue_id, size_t priority, const T &item)
 
int push_front (size_t queue_id, size_t priority, T &&item)
 
void pop_back (size_t worker_id, size_t *queue_id, size_t *priority, T *pItem)
 
void pop_back (size_t worker_id, size_t *queue_id, T *pItem)
 
size_t size (size_t queue_id) const
 Get the occupancy of the logical queue with id queue_id. More...
 
size_t size (size_t queue_id, size_t priority) const
 
void set_capacity (size_t queue_id, size_t c)
 
void set_capacity (size_t queue_id, size_t priority, size_t c)
 
void set_capacity_for_all (size_t c)
 
void set_rate (size_t queue_id, uint64_t pps)
 
void set_rate (size_t queue_id, size_t priority, uint64_t pps)
 
void set_rate_for_all (uint64_t pps)
 Set the rate of all the priority queues of all logical queues to pps. More...
 
 QueueingLogicPriRL (const QueueingLogicPriRL &)=delete
 Deleted copy constructor. More...
 
QueueingLogicPriRLoperator= (const QueueingLogicPriRL &)=delete
 Deleted copy assignment operator. More...
 
 QueueingLogicPriRL (QueueingLogicPriRL &&)=delete
 Deleted move constructor. More...
 
QueueingLogicPriRL && operator= (QueueingLogicPriRL &&)=delete
 Deleted move assignment operator. More...
 

Detailed Description

template<typename T, typename FMap>
class bm::QueueingLogicPriRL< T, FMap >

This class is slightly more advanced than QueueingLogicRL. The difference between the 2 is that this one offers the ability to set several priority queues for each logical queue. Priority queues are numbered from 0 to nb_priorities-1 (see QueueingLogicPriRL::QueueingLogicPriRL()). Priority 0 is the lowest priority queue. Each priority queue can have its own rate and its own capacity. Queues will be served in order of priority, until their respective maximum rate is reached. If no maximum rate is set, queues with a high priority can starve lower-priority queues. For example, if the queue with priority nb_priorities - 1 always contains at least one element, the other queues will never be served. As for QueueingLogicRL, the write behavior (push_front()) is not blocking: once a logical queue is full, subsequent incoming elements will be dropped until the queue starts draining again. Look at the documentation for QueueingLogic for more information about the template parameters (they are the same).

Constructor & Destructor Documentation

◆ QueueingLogicPriRL() [1/3]

template<typename T , typename FMap >
bm::QueueingLogicPriRL< T, FMap >::QueueingLogicPriRL ( size_t  nb_workers,
size_t  capacity,
FMap  map_to_worker,
size_t  nb_priorities = 2 
)
inline

See QueueingLogic::QueueingLogicRL() for an introduction. The difference here is that each logical queue can receive several priority queues (as determined by nb_priorities, which is set to 2 by default). Each of these priority queues will initially be able to hold capacity elements. The capacity of each priority queue can be changed later by using set_capacity(size_t queue_id, size_t priority, size_t c).

◆ QueueingLogicPriRL() [2/3]

template<typename T , typename FMap >
bm::QueueingLogicPriRL< T, FMap >::QueueingLogicPriRL ( const QueueingLogicPriRL< T, FMap > &  )
delete

Deleted copy constructor.

◆ QueueingLogicPriRL() [3/3]

template<typename T , typename FMap >
bm::QueueingLogicPriRL< T, FMap >::QueueingLogicPriRL ( QueueingLogicPriRL< T, FMap > &&  )
delete

Deleted move constructor.

Member Function Documentation

◆ operator=() [1/2]

template<typename T , typename FMap >
QueueingLogicPriRL& bm::QueueingLogicPriRL< T, FMap >::operator= ( const QueueingLogicPriRL< T, FMap > &  )
delete

Deleted copy assignment operator.

◆ operator=() [2/2]

template<typename T , typename FMap >
QueueingLogicPriRL&& bm::QueueingLogicPriRL< T, FMap >::operator= ( QueueingLogicPriRL< T, FMap > &&  )
delete

Deleted move assignment operator.

◆ pop_back() [1/2]

template<typename T , typename FMap >
void bm::QueueingLogicPriRL< T, FMap >::pop_back ( size_t  worker_id,
size_t *  queue_id,
size_t *  priority,
T *  pItem 
)
inline

Retrieves an element for the worker thread indentified by worker_id and moves it to pItem. The id of the logical queue which contained this element is copied to queue_id and the priority value of the served queue is copied to priority. Elements are retrieved according to the priority queue they are in (highest priority values are served first). Once a given priority queue reaches its maximum rate, the next queue is served. If no elements are available (either the queues are empty or they have exceeded their rate already), the function will block.

◆ pop_back() [2/2]

template<typename T , typename FMap >
void bm::QueueingLogicPriRL< T, FMap >::pop_back ( size_t  worker_id,
size_t *  queue_id,
T *  pItem 
)
inline

Same as pop_back(size_t worker_id, size_t *queue_id, size_t *priority, T *pItem), but the priority of the popped element is discarded.

◆ push_front() [1/2]

template<typename T , typename FMap >
int bm::QueueingLogicPriRL< T, FMap >::push_front ( size_t  queue_id,
size_t  priority,
const T &  item 
)
inline

If priority queue priority of logical queue queue_id is full, the function will return 0 immediately. Otherwise, item will be copied to the queue and the function will return 1. If queue_id or priority are incorrect, an exception of type std::out_of_range will be thrown (same if the FMap object provided to the constructor does not behave correctly).

◆ push_front() [2/2]

template<typename T , typename FMap >
int bm::QueueingLogicPriRL< T, FMap >::push_front ( size_t  queue_id,
size_t  priority,
T &&  item 
)
inline

Same as push_front(size_t queue_id, size_t priority, const T &item), but item is moved instead of copied.

◆ set_capacity() [1/2]

template<typename T , typename FMap >
void bm::QueueingLogicPriRL< T, FMap >::set_capacity ( size_t  queue_id,
size_t  c 
)
inline

Set the capacity of all the priority queues for logical queue queue_id to c elements.

◆ set_capacity() [2/2]

template<typename T , typename FMap >
void bm::QueueingLogicPriRL< T, FMap >::set_capacity ( size_t  queue_id,
size_t  priority,
size_t  c 
)
inline

Set the capacity of priority queue priority for logical queue queue_id to c elements.

◆ set_capacity_for_all()

template<typename T , typename FMap >
void bm::QueueingLogicPriRL< T, FMap >::set_capacity_for_all ( size_t  c)
inline

Set the capacity of all the priority queues of all logical queues to c elements.

◆ set_rate() [1/2]

template<typename T , typename FMap >
void bm::QueueingLogicPriRL< T, FMap >::set_rate ( size_t  queue_id,
size_t  priority,
uint64_t  pps 
)
inline

Same as set_rate(size_t queue_id, uint64_t pps) but only applies to the given priority queue.

◆ set_rate() [2/2]

template<typename T , typename FMap >
void bm::QueueingLogicPriRL< T, FMap >::set_rate ( size_t  queue_id,
uint64_t  pps 
)
inline

Set the maximum rate of all the priority queues for logical queue queue_id to pps. pps is expressed in "number of elements per second". Until this function is called, there will be no rate limit for the queue. The same behavior (no rate limit) can be achieved by calling this method with a rate of 0.

◆ set_rate_for_all()

template<typename T , typename FMap >
void bm::QueueingLogicPriRL< T, FMap >::set_rate_for_all ( uint64_t  pps)
inline

Set the rate of all the priority queues of all logical queues to pps.

◆ size() [1/2]

template<typename T , typename FMap >
size_t bm::QueueingLogicPriRL< T, FMap >::size ( size_t  queue_id) const
inline

Get the occupancy of the logical queue with id queue_id.

The occupancies of all the priority queues for this logical queue are added.

◆ size() [2/2]

template<typename T , typename FMap >
size_t bm::QueueingLogicPriRL< T, FMap >::size ( size_t  queue_id,
size_t  priority 
) const
inline

Get the occupancy of priority queue priority for logical queue with id queue_id.


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