bmv2
Designing your own switch target with bmv2
|
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... | |
QueueingLogicRL & | operator= (const QueueingLogicRL &)=delete |
Deleted copy assignment operator. More... | |
QueueingLogicRL (QueueingLogicRL &&)=delete | |
Deleted move constructor. More... | |
QueueingLogicRL && | operator= (QueueingLogicRL &&)=delete |
Deleted move assignment operator. More... | |
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.
|
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.
|
delete |
Deleted copy constructor.
|
delete |
Deleted move constructor.
|
delete |
Deleted copy assignment operator.
|
delete |
Deleted move assignment operator.
|
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.
|
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
.
|
inline |
Same as push_front(size_t queue_id, const T &item), but item
is moved instead of copied.
|
inline |
Set the capacity of the logical queue with id queue_id
to c
elements.
|
inline |
Set the capacity of all logical queues to c
elements.
|
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.
|
inline |
Set the maximum rate of all logical queues to pps
.
|
inline |
Get the occupancy of the logical queue with id queue_id
.