Skip to content

Commit f0188f9

Browse files
committed
http: use std::move to move HTTPRequest into HTTPWorkItem
Thanks to Cory Fields for the idea.
1 parent 37b2137 commit f0188f9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/httpserver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ static const size_t MAX_HEADERS_SIZE = 8192;
4444
class HTTPWorkItem : public HTTPClosure
4545
{
4646
public:
47-
HTTPWorkItem(HTTPRequest* req, const std::string &path, const HTTPRequestHandler& func):
48-
req(req), path(path), func(func)
47+
HTTPWorkItem(std::unique_ptr<HTTPRequest> req, const std::string &path, const HTTPRequestHandler& func):
48+
req(std::move(req)), path(path), func(func)
4949
{
5050
}
5151
void operator()()
@@ -281,7 +281,7 @@ static void http_request_cb(struct evhttp_request* req, void* arg)
281281

282282
// Dispatch to worker thread
283283
if (i != iend) {
284-
std::unique_ptr<HTTPWorkItem> item(new HTTPWorkItem(hreq.release(), path, i->handler));
284+
std::unique_ptr<HTTPWorkItem> item(new HTTPWorkItem(std::move(hreq), path, i->handler));
285285
assert(workQueue);
286286
if (workQueue->Enqueue(item.get()))
287287
item.release(); /* if true, queue took ownership */

0 commit comments

Comments
 (0)