3535#endif
3636#endif
3737
38- #include < boost/algorithm/string/case_conv.hpp> // for to_lower()
39- #include < boost/foreach.hpp>
40-
4138/* * Maximum size of http request (request line + headers) */
4239static const size_t MAX_HEADERS_SIZE = 8192 ;
4340
@@ -69,8 +66,8 @@ class WorkQueue
6966{
7067private:
7168 /* * Mutex protects entire object */
72- CWaitableCriticalSection cs;
73- CConditionVariable cond;
69+ std::mutex cs;
70+ std::condition_variable cond;
7471 std::deque<std::unique_ptr<WorkItem>> queue;
7572 bool running;
7673 size_t maxDepth;
@@ -83,12 +80,12 @@ class WorkQueue
8380 WorkQueue &wq;
8481 ThreadCounter (WorkQueue &w): wq(w)
8582 {
86- boost ::lock_guard<boost ::mutex> lock (wq.cs );
83+ std ::lock_guard<std ::mutex> lock (wq.cs );
8784 wq.numThreads += 1 ;
8885 }
8986 ~ThreadCounter ()
9087 {
91- boost ::lock_guard<boost ::mutex> lock (wq.cs );
88+ std ::lock_guard<std ::mutex> lock (wq.cs );
9289 wq.numThreads -= 1 ;
9390 wq.cond .notify_all ();
9491 }
@@ -109,7 +106,7 @@ class WorkQueue
109106 /* * Enqueue a work item */
110107 bool Enqueue (WorkItem* item)
111108 {
112- boost ::unique_lock<boost ::mutex> lock (cs);
109+ std ::unique_lock<std ::mutex> lock (cs);
113110 if (queue.size () >= maxDepth) {
114111 return false ;
115112 }
@@ -124,7 +121,7 @@ class WorkQueue
124121 while (running) {
125122 std::unique_ptr<WorkItem> i;
126123 {
127- boost ::unique_lock<boost ::mutex> lock (cs);
124+ std ::unique_lock<std ::mutex> lock (cs);
128125 while (running && queue.empty ())
129126 cond.wait (lock);
130127 if (!running)
@@ -138,22 +135,22 @@ class WorkQueue
138135 /* * Interrupt and exit loops */
139136 void Interrupt ()
140137 {
141- boost ::unique_lock<boost ::mutex> lock (cs);
138+ std ::unique_lock<std ::mutex> lock (cs);
142139 running = false ;
143140 cond.notify_all ();
144141 }
145142 /* * Wait for worker threads to exit */
146143 void WaitExit ()
147144 {
148- boost ::unique_lock<boost ::mutex> lock (cs);
145+ std ::unique_lock<std ::mutex> lock (cs);
149146 while (numThreads > 0 )
150147 cond.wait (lock);
151148 }
152149
153150 /* * Return current depth of queue */
154151 size_t Depth ()
155152 {
156- boost ::unique_lock<boost ::mutex> lock (cs);
153+ std ::unique_lock<std ::mutex> lock (cs);
157154 return queue.size ();
158155 }
159156};
@@ -190,7 +187,7 @@ static bool ClientAllowed(const CNetAddr& netaddr)
190187{
191188 if (!netaddr.IsValid ())
192189 return false ;
193- BOOST_FOREACH (const CSubNet& subnet, rpc_allow_subnets)
190+ for (const CSubNet& subnet : rpc_allow_subnets)
194191 if (subnet.Match (netaddr))
195192 return true ;
196193 return false ;
@@ -204,7 +201,7 @@ static bool InitHTTPAllowList()
204201 rpc_allow_subnets.push_back (CSubNet (" ::1" )); // always allow IPv6 localhost
205202 if (mapMultiArgs.count (" -rpcallowip" )) {
206203 const std::vector<std::string>& vAllow = mapMultiArgs[" -rpcallowip" ];
207- BOOST_FOREACH (std::string strAllow, vAllow) {
204+ for (std::string strAllow : vAllow) {
208205 CSubNet subnet (strAllow);
209206 if (!subnet.IsValid ()) {
210207 uiInterface.ThreadSafeMessageBox (
@@ -216,7 +213,7 @@ static bool InitHTTPAllowList()
216213 }
217214 }
218215 std::string strAllowed;
219- BOOST_FOREACH (const CSubNet& subnet, rpc_allow_subnets)
216+ for (const CSubNet& subnet : rpc_allow_subnets)
220217 strAllowed += subnet.ToString () + " " ;
221218 LogPrint (" http" , " Allowing HTTP connections from: %s\n " , strAllowed);
222219 return true ;
@@ -439,7 +436,7 @@ bool InitHTTPServer()
439436 return true ;
440437}
441438
442- boost ::thread threadHTTP;
439+ std ::thread threadHTTP;
443440std::future<bool > threadResult;
444441
445442bool StartHTTPServer ()
@@ -449,10 +446,10 @@ bool StartHTTPServer()
449446 LogPrintf (" HTTP: starting %d worker threads\n " , rpcThreads);
450447 std::packaged_task<bool (event_base*, evhttp*)> task (ThreadHTTP);
451448 threadResult = task.get_future ();
452- threadHTTP = boost ::thread (std::bind ( std:: move (task), eventBase, eventHTTP) );
449+ threadHTTP = std ::thread (std::move (task), eventBase, eventHTTP);
453450
454451 for (int i = 0 ; i < rpcThreads; i++) {
455- boost ::thread rpc_worker (HTTPWorkQueueRun, workQueue);
452+ std ::thread rpc_worker (HTTPWorkQueueRun, workQueue);
456453 rpc_worker.detach ();
457454 }
458455 return true ;
@@ -463,7 +460,7 @@ void InterruptHTTPServer()
463460 LogPrint (" http" , " Interrupting HTTP server\n " );
464461 if (eventHTTP) {
465462 // Unlisten sockets
466- BOOST_FOREACH (evhttp_bound_socket *socket, boundSockets) {
463+ for (evhttp_bound_socket *socket : boundSockets) {
467464 evhttp_del_accept_socket (eventHTTP, socket);
468465 }
469466 // Reject requests on current connections
@@ -520,7 +517,7 @@ static void httpevent_callback_fn(evutil_socket_t, short, void* data)
520517 delete self;
521518}
522519
523- HTTPEvent::HTTPEvent (struct event_base * base, bool deleteWhenTriggered, const boost ::function<void (void )>& handler):
520+ HTTPEvent::HTTPEvent (struct event_base * base, bool deleteWhenTriggered, const std ::function<void (void )>& handler):
524521 deleteWhenTriggered(deleteWhenTriggered), handler(handler)
525522{
526523 ev = event_new (base, -1 , 0 , httpevent_callback_fn, this );
@@ -602,7 +599,7 @@ void HTTPRequest::WriteReply(int nStatus, const std::string& strReply)
602599 assert (evb);
603600 evbuffer_add (evb, strReply.data (), strReply.size ());
604601 HTTPEvent* ev = new HTTPEvent (eventBase, true ,
605- boost ::bind (evhttp_send_reply, req, nStatus, (const char *)NULL , (struct evbuffer *)NULL ));
602+ std ::bind (evhttp_send_reply, req, nStatus, (const char *)NULL , (struct evbuffer *)NULL ));
606603 ev->trigger (0 );
607604 replySent = true ;
608605 req = 0 ; // transferred back to main thread
0 commit comments