Try using function2 for HttpResponse::onWritable

This commit is contained in:
Alex Hultman
2019-01-15 07:11:30 +01:00
parent 8efea340e6
commit 95cafc2c7b
3 changed files with 1624 additions and 2 deletions
+3 -1
View File
@@ -25,6 +25,8 @@
#include "HttpContextData.h"
#include "Utilities.h"
#include "f2/function2.hpp"
/* todo: tryWrite is missing currently, only send smaller segments with write */
namespace uWS {
@@ -229,7 +231,7 @@ public:
}
/* Attach handler for writable HTTP response */
HttpResponse *onWritable(std::function<bool(int)> handler) {
HttpResponse *onWritable(fu2::unique_function<bool(int)> handler) {
HttpResponseData<SSL> *httpResponseData = getHttpResponseData();
httpResponseData->onWritable = handler;
+3 -1
View File
@@ -24,6 +24,8 @@
#include "AsyncSocketData.h"
#include <functional>
#include "f2/function2.hpp"
namespace uWS {
template <bool SSL>
@@ -41,7 +43,7 @@ private:
};
/* Per socket event handlers */
std::function<bool(int)> onWritable;
fu2::unique_function<bool(int)> onWritable;
std::function<void()> onAborted;
//std::function<void()> onData;
+1618
View File
File diff suppressed because it is too large Load Diff