Initial pubsub preparatory work
This commit is contained in:
+12
-4
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user