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

Public Member Functions

 QueueingLogicRL (size_t nb_workers, size_t capacity, FMap map_to_worker)
 
int push_front (size_t queue_id, const T &item)
 
int push_front (size_t queue_id, T &&item)
 
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...
 
void set_capacity (size_t queue_id, size_t c)
 
void set_capacity_for_all (size_t c)
 Set the capacity of all logical queues to c elements. More...
 
void set_rate (size_t queue_id, uint64_t pps)
 
void set_rate_for_all (uint64_t pps)
 Set the maximum rate of all logical queues to pps. More...
 
 QueueingLogicRL (const QueueingLogicRL &)=delete
 Deleted copy constructor. More...
 
QueueingLogicRLoperator= (const QueueingLogicRL &)=delete
 Deleted copy assignment operator. More...
 
 QueueingLogicRL (QueueingLogicRL &&)=delete
 Deleted move constructor. More...
 
QueueingLogicRL && operator= (QueueingLogicRL &&)=delete
 Deleted move assignment operator. More...
 

Detailed Description

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

This class is slightly more advanced than QueueingLogic. The difference between the 2 is that this one offers the ability to rate-limit every logical queue, by providing a maximum number of elements consumed per second. If the rate is too small compared to the incoming packet rate, or if the worker thread cannot sustain the desired rate, elements are buffered in the queue. However, the write behavior (push_front()) for this class is different than the one for QueueingLogic. It is not blocking: if the queue is full, the function will return immediately and the element will not be queued. Look at the documentation for QueueingLogic for more information about the template parameters (they are the same). This is the queueing logic used by the standard simple_switch target.

Constructor & Destructor Documentation

◆ QueueingLogicRL() [1/3]

template<typename T , typename FMap >
bm::QueueingLogicRL< T, FMap >::QueueingLogicRL ( size_t  nb_workers,
size_t  capacity,
FMap  map_to_worker 
)
inline

nb_workers is the number of threads that will be consuming from the queues; they will be identified by an id in the range [0, nb_workers). capacity is the number of objects that each logical queue can hold. Because we need to be able to map each queue id to a worker id, the user has to provide a callable object of type FMap, map_to_worker, that can do this mapping. See the QueueingLogic class description for more information about the FMap template parameter.

Initially, none of the logical queues will be rate-limited, i.e. the instance will behave as an instance of QueueingLogic.

◆ QueueingLogicRL() [2/3]

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

Deleted copy constructor.

◆ QueueingLogicRL() [3/3]

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

Deleted move constructor.

Member Function Documentation

◆ operator=() [1/2]

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

Deleted copy assignment operator.

◆ operator=() [2/2]

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

Deleted move assignment operator.

◆ pop_back()

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

Retrieves the oldest 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. Note that this function will block until 1) an element is available 2) this element is free to leave the queue according to the rate limiter.

◆ push_front() [1/2]

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

If the logical queue with id queue_id is full, the function will return 0 immediately. Otherwise, item will be copied to the front of the logical queue and the function will return 1.

◆ push_front() [2/2]

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

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

◆ set_capacity()

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

Set the capacity of the logical queue with id queue_id to c elements.

◆ set_capacity_for_all()

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

Set the capacity of all logical queues to c elements.

◆ set_rate()

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

Set the maximum rate of the logical queue with id 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::QueueingLogicRL< T, FMap >::set_rate_for_all ( uint64_t  pps)
inline

Set the maximum rate of all logical queues to pps.

◆ size()

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

Get the occupancy of the logical queue with id queue_id.


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