Fix lookupTopic

This commit is contained in:
Alex Hultman
2021-04-10 22:24:11 +02:00
parent 65d1498774
commit 5df25ffa59
3 changed files with 24 additions and 19 deletions
+16 -16
View File
@@ -139,22 +139,6 @@ struct Intersection {
};
struct TopicTree {
private:
std::function<int(Subscriber *, Intersection &)> cb;
Topic *root = new Topic;
/* Global messageId for deduplication of overlapping topics and ordering between topics */
unsigned int messageId = 0;
/* Sender holes */
std::map<Subscriber *, std::vector<unsigned int>> senderHoles;
/* The triggered topics */
Topic *triggeredTopics[64];
int numTriggeredTopics = 0;
Subscriber *min = (Subscriber *) UINTPTR_MAX;
/* Returns Topic, or nullptr. Topic can be root if empty string given. */
Topic *lookupTopic(std::string_view topic) {
/* Lookup exact Topic ptr from string */
@@ -175,6 +159,22 @@ private:
return iterator;
}
private:
std::function<int(Subscriber *, Intersection &)> cb;
Topic *root = new Topic;
/* Global messageId for deduplication of overlapping topics and ordering between topics */
unsigned int messageId = 0;
/* Sender holes */
std::map<Subscriber *, std::vector<unsigned int>> senderHoles;
/* The triggered topics */
Topic *triggeredTopics[64];
int numTriggeredTopics = 0;
Subscriber *min = (Subscriber *) UINTPTR_MAX;
/* Cull or trim unused Topic nodes from leaf to root */
void trimTree(Topic *topic) {
while (!topic->subs.size() && !topic->children.size() && !topic->terminatingWildcardChild && !topic->wildcardChild) {