http: Do a pending c++11 simplification handling work items#7966
http: Do a pending c++11 simplification handling work items#7966laanwj merged 4 commits intobitcoin:masterfrom
Conversation
src/httpserver.cpp
Outdated
There was a problem hiding this comment.
Also, in C++11, you no longer need to avoid the '>>' in Template1<Template2<Template3>>.
There was a problem hiding this comment.
I was just about to ask why the space is there...
There was a problem hiding this comment.
@paveljanik because >> is an operator. But yes with c++11 this is apparently parsed differently so will remove the space.
c0c7d8b to
3fc99f4
Compare
| @@ -106,19 +105,15 @@ class WorkQueue | |||
| */ | |||
| ~WorkQueue() | |||
There was a problem hiding this comment.
Do we need an empty destructor?
There was a problem hiding this comment.
On second thought, I'm going to keep it, the precondition comment is still relevant.
fa1b71a to
d16d992
Compare
|
Decided to forget about using std::move to move items conditionally into the queue, the resulting code was too complex, the old code is cleaner. |
827a36f to
867bc6d
Compare
src/httpserver.cpp
Outdated
|
ut ACK, other than the little nit |
Use std::unique_ptr for handling work items. This makes the code more RAII and, as mentioned in the comment, is what I planned when I wrote the code in the first place.
More useful error reporting.
No need for boost here.
Thanks to Cory Fields for the idea.
867bc6d to
f0188f9
Compare
|
Fixed @theuni's nit, thanks |
f0188f9 http: use std::move to move HTTPRequest into HTTPWorkItem (Wladimir J. van der Laan) 37b2137 http: Change boost::scoped_ptr to std::unique_ptr in HTTPRequest (Wladimir J. van der Laan) f97b410 http: Add log message when work queue is full (Wladimir J. van der Laan) 091d6e0 http: Do a pending c++11 simplification (Wladimir J. van der Laan)
| return false; | ||
| } | ||
| queue.push_back(item); | ||
| queue.emplace_back(std::unique_ptr<WorkItem>(item)); |
There was a problem hiding this comment.
Creating the unique_ptr here defeats the purpose of the emplace :)
Passing it item directly would mean that the unique_ptr would be constructed in-place. As is, it's moved instead.
Not worth worrying about, just pointing it out.
There was a problem hiding this comment.
Yes by all means feel free to improve this further.
…work items f0188f9 http: use std::move to move HTTPRequest into HTTPWorkItem (Wladimir J. van der Laan) 37b2137 http: Change boost::scoped_ptr to std::unique_ptr in HTTPRequest (Wladimir J. van der Laan) f97b410 http: Add log message when work queue is full (Wladimir J. van der Laan) 091d6e0 http: Do a pending c++11 simplification (Wladimir J. van der Laan)
HTTP Server cherries from Core: bitcoin/bitcoin#6719 - Make HTTP server shutdown more graceful bitcoin/bitcoin#6859 - http: Restrict maximum size of http + headers bitcoin/bitcoin#6990 - http: speed up shutdown bitcoin/bitcoin#7966 - http: Do a pending c++11 simplification handling work items bitcoin/bitcoin#8421 - httpserver: drop boost (#8023 dependency) bitcoin/bitcoin#11006 - Improve shutdown process
HTTP Server cherries from Core: bitcoin/bitcoin#6719 - Make HTTP server shutdown more graceful bitcoin/bitcoin#6859 - http: Restrict maximum size of http + headers bitcoin/bitcoin#6990 - http: speed up shutdown bitcoin/bitcoin#7966 - http: Do a pending c++11 simplification handling work items bitcoin/bitcoin#8421 - httpserver: drop boost (#8023 dependency) bitcoin/bitcoin#11006 - Improve shutdown process
Small httpserver.cpp backports Also includes a change to the `uiInterface.NotifyBlockTip` signal API. These remove merge conflicts from subsequent backports for `sync.h`. Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6859 - bitcoin/bitcoin#7112 - Only the non-QT changes. - bitcoin/bitcoin#7966 - bitcoin/bitcoin#8421 - We already backported the second commit in #2555
Use
std::unique_ptrfor handling http work items, andstd::moveto move them into and out of the queue.This makes the code more RAII and, as mentioned in the comment, is what I planned when I wrote the code in the first place.