With C++11 available, we can use std::unique_ptr instead of the (now deprecated) std::auto_ptr. Also use std::unique_ptr in httpserver.cpp to resolve an "XXX remark" there and simplify the code.
Use std::unique_ptr instead of auto_ptr. #7983
pull domob1812 wants to merge 1 commits into bitcoin:master from domob1812:unique-ptr changing 3 files +14 −20-
domob1812 commented at 9:50 AM on May 1, 2016: contributor
-
58f954ac71
Use std::unique_ptr instead of auto_ptr.
With C++11 available, we can use std::unique_ptr instead of the (now deprecated) std::auto_ptr. Also use std::unique_ptr in httpserver.cpp to resolve an XXX remark there and simplify the code.
-
MarcoFalke commented at 10:23 AM on May 1, 2016: member
diff between the existing pulls and this one:
diff --git a/src/chain.h b/src/chain.h index 017d4fe..5b9605a 100644 --- a/src/chain.h +++ b/src/chain.h @@ -54,7 +54,7 @@ struct CDiskBlockPos }; -enum BlockStatus: uint32_t { +enum BlockStatus { //! Unused. BLOCK_VALID_UNKNOWN = 0, diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 55c81c1..64a0c31 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -34,6 +34,10 @@ #endif #endif +#include <deque> +#include <memory> +#include <utility> + #include <boost/algorithm/string/case_conv.hpp> // for to_lower() #include <boost/foreach.hpp> #include <boost/scoped_ptr.hpp> @@ -100,20 +104,14 @@ public: numThreads(0) { } - /*( Precondition: worker threads have all stopped - * (call WaitExit) - */ - ~WorkQueue() - { - } /** Enqueue a work item */ - bool Enqueue(std::unique_ptr<WorkItem> item) + bool Enqueue(WorkItem* item) { boost::unique_lock<boost::mutex> lock(cs); if (queue.size() >= maxDepth) { return false; } - queue.push_back(std::move(item)); + queue.push_back(std::unique_ptr<WorkItem>(item)); cond.notify_one(); return true; } @@ -284,7 +282,9 @@ static void http_request_cb(struct evhttp_request* req, void* arg) if (i != iend) { std::unique_ptr<HTTPWorkItem> item(new HTTPWorkItem(hreq.release(), path, i->handler)); assert(workQueue); - if (!workQueue->Enqueue(std::move(item))) + if (workQueue->Enqueue(item.get())) + item.release(); /* if true, queue took ownership */ + else item->req->WriteReply(HTTP_INTERNAL, "Work queue depth exceeded"); } else { hreq->WriteReply(HTTP_NOTFOUND); diff --git a/src/miner.cpp b/src/miner.cpp index eaf29a7..d4aec3c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -27,6 +27,7 @@ #include <boost/thread.hpp> #include <boost/tuple/tuple.hpp> +#include <memory> #include <queue> using namespace std; diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 9a7d9d5..eeb8675 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -21,6 +21,7 @@ #include "utilstrencodings.h" #include "validationinterface.h" +#include <memory> #include <stdint.h> #include <boost/assign/list_of.hpp> - MarcoFalke added the label Refactoring on May 1, 2016
-
domob1812 commented at 10:30 AM on May 1, 2016: contributor
Well, ok, I guess then nothing remains of this patch and the PR can be closed....
- laanwj closed this on May 2, 2016
-
laanwj commented at 11:11 AM on May 2, 2016: member
Right, the overlap with other pulls is too large, closing.
- domob1812 deleted the branch on May 2, 2016
- DrahtBot locked this on Sep 8, 2021
Contributors
Labels