Auto merge of #4324 - zancas:4323_replace_boost_fn_w_std_fn, r=str4d
Replace boost::function with std::function Fixes: #4323 This logic is cherry-picked from the relevant commit, as referenced here: https://github.com/bitcoin/bitcoin/pull/10395
This commit is contained in:
commit
a2d719b9ff
|
@ -26,7 +26,7 @@ static const char* WWW_AUTH_HEADER_DATA = "Basic realm=\"jsonrpc\"";
|
|||
class HTTPRPCTimer : public RPCTimerBase
|
||||
{
|
||||
public:
|
||||
HTTPRPCTimer(struct event_base* eventBase, boost::function<void(void)>& func, int64_t millis) :
|
||||
HTTPRPCTimer(struct event_base* eventBase, std::function<void(void)>& func, int64_t millis) :
|
||||
ev(eventBase, false, func)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
@ -48,7 +48,7 @@ public:
|
|||
{
|
||||
return "HTTP";
|
||||
}
|
||||
RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis)
|
||||
RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis)
|
||||
{
|
||||
return new HTTPRPCTimer(base, func, millis);
|
||||
}
|
||||
|
|
|
@ -518,7 +518,7 @@ static void httpevent_callback_fn(evutil_socket_t, short, void* data)
|
|||
delete self;
|
||||
}
|
||||
|
||||
HTTPEvent::HTTPEvent(struct event_base* base, bool deleteWhenTriggered, const boost::function<void(void)>& handler):
|
||||
HTTPEvent::HTTPEvent(struct event_base* base, bool deleteWhenTriggered, const std::function<void(void)>& handler):
|
||||
deleteWhenTriggered(deleteWhenTriggered), handler(handler)
|
||||
{
|
||||
ev = event_new(base, -1, 0, httpevent_callback_fn, this);
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <stdint.h>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/function.hpp>
|
||||
|
||||
static const int DEFAULT_HTTP_THREADS=4;
|
||||
static const int DEFAULT_HTTP_WORKQUEUE=16;
|
||||
|
@ -35,7 +34,7 @@ void InterruptHTTPServer();
|
|||
void StopHTTPServer();
|
||||
|
||||
/** Handler for requests to a certain HTTP path */
|
||||
typedef boost::function<void(HTTPRequest* req, const std::string &)> HTTPRequestHandler;
|
||||
typedef std::function<void(HTTPRequest* req, const std::string &)> HTTPRequestHandler;
|
||||
/** Register handler for prefix.
|
||||
* If multiple handlers match a prefix, the first-registered one will
|
||||
* be invoked.
|
||||
|
@ -135,7 +134,7 @@ public:
|
|||
* deleteWhenTriggered deletes this event object after the event is triggered (and the handler called)
|
||||
* handler is the handler to call when the event is triggered.
|
||||
*/
|
||||
HTTPEvent(struct event_base* base, bool deleteWhenTriggered, const boost::function<void(void)>& handler);
|
||||
HTTPEvent(struct event_base* base, bool deleteWhenTriggered, const std::function<void(void)>& handler);
|
||||
~HTTPEvent();
|
||||
|
||||
/** Trigger the event. If tv is 0, trigger it immediately. Otherwise trigger it after
|
||||
|
@ -144,7 +143,7 @@ public:
|
|||
void trigger(struct timeval* tv);
|
||||
|
||||
bool deleteWhenTriggered;
|
||||
boost::function<void(void)> handler;
|
||||
std::function<void(void)> handler;
|
||||
private:
|
||||
struct event* ev;
|
||||
};
|
||||
|
|
|
@ -56,8 +56,6 @@
|
|||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/interprocess/sync/file_lock.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <openssl/crypto.h>
|
||||
|
|
|
@ -49,22 +49,22 @@ static struct CRPCSignals
|
|||
boost::signals2::signal<void (const CRPCCommand&)> PostCommand;
|
||||
} g_rpcSignals;
|
||||
|
||||
void RPCServer::OnStarted(boost::function<void ()> slot)
|
||||
void RPCServer::OnStarted(std::function<void ()> slot)
|
||||
{
|
||||
g_rpcSignals.Started.connect(slot);
|
||||
}
|
||||
|
||||
void RPCServer::OnStopped(boost::function<void ()> slot)
|
||||
void RPCServer::OnStopped(std::function<void ()> slot)
|
||||
{
|
||||
g_rpcSignals.Stopped.connect(slot);
|
||||
}
|
||||
|
||||
void RPCServer::OnPreCommand(boost::function<void (const CRPCCommand&)> slot)
|
||||
void RPCServer::OnPreCommand(std::function<void (const CRPCCommand&)> slot)
|
||||
{
|
||||
g_rpcSignals.PreCommand.connect(boost::bind(slot, _1));
|
||||
}
|
||||
|
||||
void RPCServer::OnPostCommand(boost::function<void (const CRPCCommand&)> slot)
|
||||
void RPCServer::OnPostCommand(std::function<void (const CRPCCommand&)> slot)
|
||||
{
|
||||
g_rpcSignals.PostCommand.connect(boost::bind(slot, _1));
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ void RPCUnregisterTimerInterface(RPCTimerInterface *iface)
|
|||
timerInterfaces.erase(i);
|
||||
}
|
||||
|
||||
void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64_t nSeconds)
|
||||
void RPCRunLater(const std::string& name, std::function<void(void)> func, int64_t nSeconds)
|
||||
{
|
||||
if (timerInterfaces.empty())
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "No timer handler registered for RPC");
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include <boost/function.hpp>
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
class AsyncRPCQueue;
|
||||
|
@ -25,10 +23,10 @@ class CRPCCommand;
|
|||
|
||||
namespace RPCServer
|
||||
{
|
||||
void OnStarted(boost::function<void ()> slot);
|
||||
void OnStopped(boost::function<void ()> slot);
|
||||
void OnPreCommand(boost::function<void (const CRPCCommand&)> slot);
|
||||
void OnPostCommand(boost::function<void (const CRPCCommand&)> slot);
|
||||
void OnStarted(std::function<void ()> slot);
|
||||
void OnStopped(std::function<void ()> slot);
|
||||
void OnPreCommand(std::function<void (const CRPCCommand&)> slot);
|
||||
void OnPostCommand(std::function<void (const CRPCCommand&)> slot);
|
||||
}
|
||||
|
||||
class CBlockIndex;
|
||||
|
@ -103,7 +101,7 @@ public:
|
|||
* This is needed to cope with the case in which there is no HTTP server, but
|
||||
* only GUI RPC console, and to break the dependency of rpcserver on httprpc.
|
||||
*/
|
||||
virtual RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis) = 0;
|
||||
virtual RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis) = 0;
|
||||
};
|
||||
|
||||
/** Register factory function for timers */
|
||||
|
@ -115,7 +113,7 @@ void RPCUnregisterTimerInterface(RPCTimerInterface *iface);
|
|||
* Run func nSeconds from now.
|
||||
* Overrides previous timer <name> (if any).
|
||||
*/
|
||||
void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64_t nSeconds);
|
||||
void RPCRunLater(const std::string& name, std::function<void(void)> func, int64_t nSeconds);
|
||||
|
||||
typedef UniValue(*rpcfn_type)(const UniValue& params, bool fHelp);
|
||||
|
||||
|
|
|
@ -7,10 +7,9 @@
|
|||
|
||||
//
|
||||
// NOTE:
|
||||
// boost::thread / boost::function / boost::chrono should be ported to
|
||||
// std::thread / std::function / std::chrono when we support C++11.
|
||||
// boost::thread / boost::chrono should be ported to std::thread / std::chrono
|
||||
// when we support C++11.
|
||||
//
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/chrono/chrono.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <map>
|
||||
|
@ -39,7 +38,7 @@ public:
|
|||
CScheduler();
|
||||
~CScheduler();
|
||||
|
||||
typedef boost::function<void(void)> Function;
|
||||
typedef std::function<void(void)> Function;
|
||||
|
||||
// Call func at/after time t
|
||||
void schedule(Function f, boost::chrono::system_clock::time_point t);
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include <set>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/signals2/signal.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
@ -73,8 +72,8 @@ public:
|
|||
class TorControlConnection
|
||||
{
|
||||
public:
|
||||
typedef boost::function<void(TorControlConnection&)> ConnectionCB;
|
||||
typedef boost::function<void(TorControlConnection &,const TorControlReply &)> ReplyHandlerCB;
|
||||
typedef std::function<void(TorControlConnection&)> ConnectionCB;
|
||||
typedef std::function<void(TorControlConnection &,const TorControlReply &)> ReplyHandlerCB;
|
||||
|
||||
/** Create a new TorControlConnection.
|
||||
*/
|
||||
|
@ -105,9 +104,9 @@ public:
|
|||
boost::signals2::signal<void(TorControlConnection &,const TorControlReply &)> async_handler;
|
||||
private:
|
||||
/** Callback when ready for use */
|
||||
boost::function<void(TorControlConnection&)> connected;
|
||||
std::function<void(TorControlConnection&)> connected;
|
||||
/** Callback when connection lost */
|
||||
boost::function<void(TorControlConnection&)> disconnected;
|
||||
std::function<void(TorControlConnection&)> disconnected;
|
||||
/** Libevent event base */
|
||||
struct event_base *base;
|
||||
/** Connection to control socket */
|
||||
|
|
|
@ -456,7 +456,7 @@ bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CBlockTreeDB::LoadBlockIndexGuts(boost::function<CBlockIndex*(const uint256&)> insertBlockIndex)
|
||||
bool CBlockTreeDB::LoadBlockIndexGuts(std::function<CBlockIndex*(const uint256&)> insertBlockIndex)
|
||||
{
|
||||
boost::scoped_ptr<CDBIterator> pcursor(NewIterator());
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/function.hpp>
|
||||
|
||||
class CBlockIndex;
|
||||
|
||||
// START insightexplorer
|
||||
|
@ -134,7 +132,7 @@ public:
|
|||
|
||||
bool WriteFlag(const std::string &name, bool fValue);
|
||||
bool ReadFlag(const std::string &name, bool &fValue);
|
||||
bool LoadBlockIndexGuts(boost::function<CBlockIndex*(const uint256&)> insertBlockIndex);
|
||||
bool LoadBlockIndexGuts(std::function<CBlockIndex*(const uint256&)> insertBlockIndex);
|
||||
};
|
||||
|
||||
#endif // BITCOIN_TXDB_H
|
||||
|
|
Loading…
Reference in New Issue