Initial integration of new topicTree

This commit is contained in:
Alex Hultman
2021-01-28 17:26:02 +01:00
parent af8094268c
commit ac7c72698d
3 changed files with 10 additions and 4 deletions
+2 -2
View File
@@ -76,13 +76,13 @@ struct Intersection {
std::pair<std::string, std::string> dataChannels;
std::vector<Hole> holes;
void forSubscriber(Subscriber *s, std::vector<unsigned int> &senderForMessages, std::function<void(std::pair<std::string_view, std::string_view>)> cb) {
void forSubscriber(std::vector<unsigned int> &senderForMessages, std::function<void(std::pair<std::string_view, std::string_view>)> cb) {
/* How far we already emitted of the two dataChannels */
std::pair<size_t, size_t> emitted = {};
/* Holes are global to the entire topic tree, so we are not guaranteed to find
* holes in this intersection - they are sorted, though */
int examinedHoles = 0;
unsigned int examinedHoles = 0;
/* This is a slow path of sorts, most subscribers will be observers, not active senders */
for (unsigned int id : senderForMessages) {
+7 -1
View File
@@ -76,7 +76,13 @@ public:
Loop::get()->removePreHandler(this);
}
WebSocketContextData() : topicTree([this](Subscriber *s, std::pair<std::string_view, std::string_view> data) -> int {
WebSocketContextData() : topicTree([this](Subscriber *s, Intersection &intersection) -> int {
std::pair<std::string_view, std::string_view> data = intersection.dataChannels;
/* We rely on writing to regular asyncSockets */
auto *asyncSocket = (AsyncSocket<SSL> *) s->user;
+1 -1
View File
@@ -19,7 +19,7 @@ void testCorrectness() {
topicTree = new uWS::TopicTree([&topicTree, &actualResult](uWS::Subscriber *s, uWS::Intersection &intersection) {
intersection.forSubscriber(s, topicTree->getSenderFor(s), [s, &actualResult](std::pair<std::string_view, std::string_view> dataChannels) {
intersection.forSubscriber(topicTree->getSenderFor(s), [s, &actualResult](std::pair<std::string_view, std::string_view> dataChannels) {
actualResult[s].first += dataChannels.first;
actualResult[s].second += dataChannels.second;
});