Merge #10395: Replace boost::function with std::function (C++11)
1b936f5 Replace boost::function with std::function (C++11) (practicalswift) Tree-SHA512: c4faec8cf3f801842010976115681f68ffa08fbc97ba50b22e95c936840f47e1b3bd8d7fd2f5b4e094b5a46bf3d29fc90b69d975a99e77322c0d19f8a00d53d3
This commit is contained in:
parent
6b548bf37a
commit
2e050ea744
@ -5,6 +5,7 @@
|
|||||||
#include "bench.h"
|
#include "bench.h"
|
||||||
#include "perf.h"
|
#include "perf.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
@ -5,10 +5,11 @@
|
|||||||
#ifndef BITCOIN_BENCH_BENCH_H
|
#ifndef BITCOIN_BENCH_BENCH_H
|
||||||
#define BITCOIN_BENCH_BENCH_H
|
#define BITCOIN_BENCH_BENCH_H
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <limits>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
|
||||||
#include <boost/preprocessor/cat.hpp>
|
#include <boost/preprocessor/cat.hpp>
|
||||||
#include <boost/preprocessor/stringize.hpp>
|
#include <boost/preprocessor/stringize.hpp>
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ namespace benchmark {
|
|||||||
bool KeepRunning();
|
bool KeepRunning();
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef boost::function<void(State&)> BenchFunction;
|
typedef std::function<void(State&)> BenchFunction;
|
||||||
|
|
||||||
class BenchRunner
|
class BenchRunner
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ static const char* WWW_AUTH_HEADER_DATA = "Basic realm=\"jsonrpc\"";
|
|||||||
class HTTPRPCTimer : public RPCTimerBase
|
class HTTPRPCTimer : public RPCTimerBase
|
||||||
{
|
{
|
||||||
public:
|
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)
|
ev(eventBase, false, func)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
@ -52,7 +52,7 @@ public:
|
|||||||
{
|
{
|
||||||
return "HTTP";
|
return "HTTP";
|
||||||
}
|
}
|
||||||
RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis) override
|
RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis) override
|
||||||
{
|
{
|
||||||
return new HTTPRPCTimer(base, func, millis);
|
return new HTTPRPCTimer(base, func, millis);
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,6 @@
|
|||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
#include <boost/algorithm/string/split.hpp>
|
#include <boost/algorithm/string/split.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/function.hpp>
|
|
||||||
#include <boost/interprocess/sync/file_lock.hpp>
|
#include <boost/interprocess/sync/file_lock.hpp>
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
#include <openssl/crypto.h>
|
#include <openssl/crypto.h>
|
||||||
|
@ -108,7 +108,7 @@ class QtRPCTimerBase: public QObject, public RPCTimerBase
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
QtRPCTimerBase(boost::function<void(void)>& _func, int64_t millis):
|
QtRPCTimerBase(std::function<void(void)>& _func, int64_t millis):
|
||||||
func(_func)
|
func(_func)
|
||||||
{
|
{
|
||||||
timer.setSingleShot(true);
|
timer.setSingleShot(true);
|
||||||
@ -120,7 +120,7 @@ private Q_SLOTS:
|
|||||||
void timeout() { func(); }
|
void timeout() { func(); }
|
||||||
private:
|
private:
|
||||||
QTimer timer;
|
QTimer timer;
|
||||||
boost::function<void(void)> func;
|
std::function<void(void)> func;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QtRPCTimerInterface: public RPCTimerInterface
|
class QtRPCTimerInterface: public RPCTimerInterface
|
||||||
@ -128,7 +128,7 @@ class QtRPCTimerInterface: public RPCTimerInterface
|
|||||||
public:
|
public:
|
||||||
~QtRPCTimerInterface() {}
|
~QtRPCTimerInterface() {}
|
||||||
const char *Name() override { return "Qt"; }
|
const char *Name() override { return "Qt"; }
|
||||||
RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis) override
|
RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis) override
|
||||||
{
|
{
|
||||||
return new QtRPCTimerBase(func, millis);
|
return new QtRPCTimerBase(func, millis);
|
||||||
}
|
}
|
||||||
|
@ -46,17 +46,17 @@ static struct CRPCSignals
|
|||||||
boost::signals2::signal<void (const CRPCCommand&)> PreCommand;
|
boost::signals2::signal<void (const CRPCCommand&)> PreCommand;
|
||||||
} g_rpcSignals;
|
} g_rpcSignals;
|
||||||
|
|
||||||
void RPCServer::OnStarted(boost::function<void ()> slot)
|
void RPCServer::OnStarted(std::function<void ()> slot)
|
||||||
{
|
{
|
||||||
g_rpcSignals.Started.connect(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);
|
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));
|
g_rpcSignals.PreCommand.connect(boost::bind(slot, _1));
|
||||||
}
|
}
|
||||||
@ -595,7 +595,7 @@ void RPCUnsetTimerInterface(RPCTimerInterface *iface)
|
|||||||
timerInterface = NULL;
|
timerInterface = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 (!timerInterface)
|
if (!timerInterface)
|
||||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "No timer handler registered for RPC");
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "No timer handler registered for RPC");
|
||||||
|
@ -15,17 +15,15 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
|
||||||
|
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
|
||||||
class CRPCCommand;
|
class CRPCCommand;
|
||||||
|
|
||||||
namespace RPCServer
|
namespace RPCServer
|
||||||
{
|
{
|
||||||
void OnStarted(boost::function<void ()> slot);
|
void OnStarted(std::function<void ()> slot);
|
||||||
void OnStopped(boost::function<void ()> slot);
|
void OnStopped(std::function<void ()> slot);
|
||||||
void OnPreCommand(boost::function<void (const CRPCCommand&)> slot);
|
void OnPreCommand(std::function<void (const CRPCCommand&)> slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
@ -113,7 +111,7 @@ public:
|
|||||||
* This is needed to cope with the case in which there is no HTTP server, but
|
* 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 pcserver on httprpc.
|
* only GUI RPC console, and to break the dependency of pcserver 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Set the factory function for timers */
|
/** Set the factory function for timers */
|
||||||
@ -127,7 +125,7 @@ void RPCUnsetTimerInterface(RPCTimerInterface *iface);
|
|||||||
* Run func nSeconds from now.
|
* Run func nSeconds from now.
|
||||||
* Overrides previous timer <name> (if any).
|
* 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 JSONRPCRequest& jsonRequest);
|
typedef UniValue(*rpcfn_type)(const JSONRPCRequest& jsonRequest);
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
// NOTE:
|
// NOTE:
|
||||||
// boost::thread / boost::function / boost::chrono should be ported to
|
// boost::thread / boost::chrono should be ported to std::thread / std::chrono
|
||||||
// std::thread / std::function / std::chrono when we support C++11.
|
// when we support C++11.
|
||||||
//
|
//
|
||||||
#include <boost/chrono/chrono.hpp>
|
#include <boost/chrono/chrono.hpp>
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/signals2/signal.hpp>
|
#include <boost/signals2/signal.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
@ -73,8 +72,8 @@ public:
|
|||||||
class TorControlConnection
|
class TorControlConnection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef boost::function<void(TorControlConnection&)> ConnectionCB;
|
typedef std::function<void(TorControlConnection&)> ConnectionCB;
|
||||||
typedef boost::function<void(TorControlConnection &,const TorControlReply &)> ReplyHandlerCB;
|
typedef std::function<void(TorControlConnection &,const TorControlReply &)> ReplyHandlerCB;
|
||||||
|
|
||||||
/** Create a new TorControlConnection.
|
/** Create a new TorControlConnection.
|
||||||
*/
|
*/
|
||||||
@ -105,9 +104,9 @@ public:
|
|||||||
boost::signals2::signal<void(TorControlConnection &,const TorControlReply &)> async_handler;
|
boost::signals2::signal<void(TorControlConnection &,const TorControlReply &)> async_handler;
|
||||||
private:
|
private:
|
||||||
/** Callback when ready for use */
|
/** Callback when ready for use */
|
||||||
boost::function<void(TorControlConnection&)> connected;
|
std::function<void(TorControlConnection&)> connected;
|
||||||
/** Callback when connection lost */
|
/** Callback when connection lost */
|
||||||
boost::function<void(TorControlConnection&)> disconnected;
|
std::function<void(TorControlConnection&)> disconnected;
|
||||||
/** Libevent event base */
|
/** Libevent event base */
|
||||||
struct event_base *base;
|
struct event_base *base;
|
||||||
/** Connection to control socket */
|
/** Connection to control socket */
|
||||||
|
@ -344,7 +344,7 @@ bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBlockTreeDB::LoadBlockIndexGuts(boost::function<CBlockIndex*(const uint256&)> insertBlockIndex)
|
bool CBlockTreeDB::LoadBlockIndexGuts(std::function<CBlockIndex*(const uint256&)> insertBlockIndex)
|
||||||
{
|
{
|
||||||
std::unique_ptr<CDBIterator> pcursor(NewIterator());
|
std::unique_ptr<CDBIterator> pcursor(NewIterator());
|
||||||
|
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
|
||||||
|
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
class CCoinsViewDBCursor;
|
class CCoinsViewDBCursor;
|
||||||
class uint256;
|
class uint256;
|
||||||
@ -138,7 +136,7 @@ public:
|
|||||||
bool ReadTimestampIndex(const unsigned int &high, const unsigned int &low, std::vector<uint256> &vect);
|
bool ReadTimestampIndex(const unsigned int &high, const unsigned int &low, std::vector<uint256> &vect);
|
||||||
bool WriteFlag(const std::string &name, bool fValue);
|
bool WriteFlag(const std::string &name, bool fValue);
|
||||||
bool ReadFlag(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
|
#endif // BITCOIN_TXDB_H
|
||||||
|
Loading…
Reference in New Issue
Block a user