Template Class RTEMempool

Template Parameter Order

  1. typename Elem

  2. MbufType type

Class Documentation

template<typename Elem, MbufType type = MbufType::Raw>
class RTEMempool

Class wrapping an RTEMempool.

In contrast to RTEPktMempool, this mempool is used to allocate raw types, rather than ones wrapped in an rte_mbuf. Template argument Elem determines the size of elements allocated from this mempool. Since this data structure can be shared accross threads, an std::shared_ptr is used to manage ownership.

Public Functions

RTEMempool(const RTEMempool&) = delete
RTEMempool &operator=(const RTEMempool&) = delete
inline RTEMempool(RTEMempool &&other)
inline RTEMempool &operator=(RTEMempool &&other)
inline ~RTEMempool()

Destructs the mempool if it has a valid pointer.

inline size_t count() const

Returns the number of elements currently in the mempool.

inline size_t capacity() const

Returns the capacity of the mempool.

inline rte_mempool *get()

Get the pointer to the mempool.

Returns:

std::shared_ptr containing the pointer to the mempool.

Public Static Functions

static inline tl::expected<RTEMempool, int> init(const std::string &name, size_t num_elems, size_t cache_size, size_t private_size, unsigned int flags, unsigned int socket_id = rte_socket_id())

Constructs an RTEMempool.

If the construction fails an error is printed to stderr and the application is exited.

Parameters:
  • name – Name of the mempool - MUST be unique.

  • num_elems – Number of elements this mempool is able to allocate.

  • cache_size – Size of cache of the mempool, usually 0.

  • private_size – Size of the private area after the mempool allocation, usually 0.

  • socket_id – Socket ID to allocate this mempool to.

  • flags – See DPDK documentation for which flags can be set.

static inline tl::expected<RTEMempool, int> init(const std::string &name, size_t pool_size, size_t cache_size, size_t priv_size, int socket_id = rte_socket_id())

Construct a new RTEPktMempool.

Calls rte_pktmbuf_pool_create().

When the constructor fails an error message will be printed to stderr, and the application will be exited.

Parameters:
  • name – Name of the mempool - MUST be unique.

  • pool_size – Size of the pool, in number of elements.

  • cache_size – Size of the cache to allocate for this mempool, usually 0.

  • priv_size – Size of private area for each mbuf, usually 0.

  • socket_id – Socket ID to allocate this mempool to.