Initial pubsub preparatory work

This commit is contained in:
Alex Hultman
2019-02-09 01:00:17 +01:00
parent aaf1f05dcd
commit f08bc8cd03
4 changed files with 66 additions and 9 deletions
+12 -4
View File
@@ -21,12 +21,8 @@
/* The loop is lazily created per-thread and run with uWS::run() */
#include "LoopData.h"
#include <libusockets_new.h>
#include <iostream>
namespace uWS {
@@ -62,6 +58,11 @@ private:
if (loopData->postHandler) {
loopData->postHandler((Loop *) loop);
}
/* We should move over to using only these */
for (auto &f : loopData->postHandlers) {
f((Loop *) loop);
}
}
Loop() = delete;
@@ -109,6 +110,13 @@ public:
us_loop_free((us_loop *) this);
}
/* We want to have multiple of these */
void addPostHandler(fu2::unique_function<void(Loop *)> &&handler) {
LoopData *loopData = (LoopData *) us_loop_ext((us_loop *) this);
loopData->postHandlers.emplace_back(std::move(handler));
}
/* Set postCb callback */
void setPostHandler(fu2::unique_function<void(Loop *)> &&handler) {
LoopData *loopData = (LoopData *) us_loop_ext((us_loop *) this);