DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DpdkMempool.cpp
Go to the documentation of this file.
1
9
10#include <rte_mempool.h>
11
12#include <map>
13#include <memory>
14
15namespace dunedaq::dpdklibs {
16
17void
18MempoolDeleter::operator()(rte_mempool* pool) const noexcept
19{
20 if (pool != nullptr) {
21 rte_mempool_free(pool);
22 }
23}
24
26take_mempool_ownership(std::unique_ptr<rte_mempool>&& legacy)
27{
28 return unique_mempool(legacy.release());
29}
30
32{
33 for (auto& [index, pool] : m_map) { // NOLINT(readability-qualified-auto)
34 pool.release(); // NOLINT(bugprone-unused-return-value) borrowed; not owned by this map
35 }
36}
37
38void
39BorrowedPoolMap::borrow(int index, rte_mempool* pool)
40{
41 m_map[index].reset(pool);
42}
43
44std::map<int, std::unique_ptr<rte_mempool>>&
46{
47 return m_map;
48}
49
50} // namespace dunedaq::dpdklibs
void borrow(int index, rte_mempool *pool)
std::map< int, std::unique_ptr< rte_mempool > > & get()
std::map< int, std::unique_ptr< rte_mempool > > m_map
unique_mempool take_mempool_ownership(std::unique_ptr< rte_mempool > &&legacy)
std::unique_ptr< rte_mempool, MempoolDeleter > unique_mempool
void operator()(rte_mempool *pool) const noexcept