packet matcher uses refactored pool now

This commit is contained in:
Robin Müller 2020-10-15 13:45:47 +02:00
parent 7d358483dd
commit bd2f8b3e8c
2 changed files with 19 additions and 12 deletions

View File

@ -3,19 +3,30 @@
#include "ServiceMatcher.h" #include "ServiceMatcher.h"
#include "SubserviceMatcher.h" #include "SubserviceMatcher.h"
// This should be configurable..
const LocalPool::LocalPoolConfig PacketMatchTree::poolConfig = {
{10, sizeof(ServiceMatcher)},
{20, sizeof(SubServiceMatcher)},
{2, sizeof(ApidMatcher)},
{40, sizeof(PacketMatchTree::Node)}
};
PacketMatchTree::PacketMatchTree(Node* root) : PacketMatchTree::PacketMatchTree(Node* root) :
MatchTree<TmPacketMinimal*>(root, 2), factoryBackend(0, POOL_SIZES, MatchTree<TmPacketMinimal*>(root, 2),
N_ELEMENTS, false, true), factory(&factoryBackend) { factoryBackend(0, poolConfig, false, true),
factory(&factoryBackend) {
} }
PacketMatchTree::PacketMatchTree(iterator root) : PacketMatchTree::PacketMatchTree(iterator root) :
MatchTree<TmPacketMinimal*>(root.element, 2), factoryBackend(0, MatchTree<TmPacketMinimal*>(root.element, 2),
POOL_SIZES, N_ELEMENTS, false, true), factory(&factoryBackend) { factoryBackend(0, poolConfig, false, true),
factory(&factoryBackend) {
} }
PacketMatchTree::PacketMatchTree() : PacketMatchTree::PacketMatchTree() :
MatchTree<TmPacketMinimal*>((Node*) NULL, 2), factoryBackend(0, MatchTree<TmPacketMinimal*>((Node*) NULL, 2),
POOL_SIZES, N_ELEMENTS, false, true), factory(&factoryBackend) { factoryBackend(0, poolConfig, false, true),
factory(&factoryBackend) {
} }
PacketMatchTree::~PacketMatchTree() { PacketMatchTree::~PacketMatchTree() {
@ -172,11 +183,6 @@ ReturnValue_t PacketMatchTree::initialize() {
return factoryBackend.initialize(); return factoryBackend.initialize();
} }
const uint16_t PacketMatchTree::POOL_SIZES[N_POOLS] = { sizeof(ServiceMatcher),
sizeof(SubServiceMatcher), sizeof(ApidMatcher),
sizeof(PacketMatchTree::Node) };
//Maximum number of types and subtypes to filter should be more than sufficient.
const uint16_t PacketMatchTree::N_ELEMENTS[N_POOLS] = { 10, 20, 2, 40 };
ReturnValue_t PacketMatchTree::changeMatch(bool addToMatch, uint16_t apid, ReturnValue_t PacketMatchTree::changeMatch(bool addToMatch, uint16_t apid,
uint8_t type, uint8_t subtype) { uint8_t type, uint8_t subtype) {

View File

@ -23,8 +23,9 @@ protected:
ReturnValue_t cleanUpElement(iterator position); ReturnValue_t cleanUpElement(iterator position);
private: private:
static const uint8_t N_POOLS = 4; static const uint8_t N_POOLS = 4;
LocalPool<N_POOLS> factoryBackend; LocalPool factoryBackend;
PlacementFactory factory; PlacementFactory factory;
static const LocalPool::LocalPoolConfig poolConfig;
static const uint16_t POOL_SIZES[N_POOLS]; static const uint16_t POOL_SIZES[N_POOLS];
static const uint16_t N_ELEMENTS[N_POOLS]; static const uint16_t N_ELEMENTS[N_POOLS];
template<typename VALUE_T, typename INSERTION_T> template<typename VALUE_T, typename INSERTION_T>