Replace boost::bind with BIND_TYPE where appropriate

This commit is contained in:
Vinnie Falco
2013-06-28 09:18:17 -07:00
parent 6cd0c27a0d
commit f1a4ea3c3f
14 changed files with 58 additions and 32 deletions

View File

@@ -12,7 +12,7 @@
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup> <ItemDefinitionGroup>
<ClCompile> <ClCompile>
<PreprocessorDefinitions>_VARIADIC_MAX=8;_WIN32_WINNT=0x0600;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_VARIADIC_MAX=10;_WIN32_WINNT=0x0600;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>$(RepoDir);$(RepoDir)\src\cpp\protobuf\src;$(RepoDir)\src\cpp\protobuf\vsprojects;$(RepoDir)\build\proto;$(RepoDir)\Subtrees;$(RepoDir)\Subtrees\leveldb;$(RepoDir)\Subtrees\leveldb\include;$(RepoDir)\Subtrees\beast;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(RepoDir);$(RepoDir)\src\cpp\protobuf\src;$(RepoDir)\src\cpp\protobuf\vsprojects;$(RepoDir)\build\proto;$(RepoDir)\Subtrees;$(RepoDir)\Subtrees\leveldb;$(RepoDir)\Subtrees\leveldb\include;$(RepoDir)\Subtrees\beast;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

View File

@@ -26,6 +26,28 @@
#include "system/ripple_OpenSSLIncludes.h" #include "system/ripple_OpenSSLIncludes.h"
//------------------------------------------------------------------------------
// From
// http://stackoverflow.com/questions/4682343/how-to-resolve-conflict-between-boostshared-ptr-and-using-stdshared-ptr
//
namespace boost
{
template <class T>
const T* get_pointer (std::shared_ptr<T> const& ptr)
{
return ptr.get();
}
template <class T>
T* get_pointer (std::shared_ptr<T>& ptr)
{
return ptr.get();
}
}
//------------------------------------------------------------------------------
// ByteOrder // ByteOrder
#ifdef WIN32 #ifdef WIN32
// (nothing) // (nothing)

View File

@@ -306,7 +306,7 @@ bool LedgerMaster::acquireMissingLedger (Ledger::ref origLedger, uint256 const&
if (mMissingLedger->setAccept ()) if (mMissingLedger->setAccept ())
{ {
if (!mMissingLedger->addOnComplete (BIND_TYPE (&LedgerMaster::missingAcquireComplete, this, P_1))) if (!mMissingLedger->addOnComplete (BIND_TYPE (&LedgerMaster::missingAcquireComplete, this, P_1)))
theApp->getIOService ().post (boost::bind (&LedgerMaster::missingAcquireComplete, this, mMissingLedger)); theApp->getIOService ().post (BIND_TYPE (&LedgerMaster::missingAcquireComplete, this, mMissingLedger));
} }
int fetchMax = theConfig.getSize (siLedgerFetch); int fetchMax = theConfig.getSize (siLedgerFetch);

View File

@@ -312,7 +312,7 @@ void NetworkOPs::runTransactionQueue ()
} }
if (theApp->getTxnQueue ().stopProcessing (txn)) if (theApp->getTxnQueue ().stopProcessing (txn))
theApp->getIOService ().post (boost::bind (&NetworkOPs::runTransactionQueue, this)); theApp->getIOService ().post (BIND_TYPE (&NetworkOPs::runTransactionQueue, this));
} }
Transaction::pointer NetworkOPs::processTransaction (Transaction::pointer trans, bool bAdmin, bool bFailHard, stCallback callback) Transaction::pointer NetworkOPs::processTransaction (Transaction::pointer trans, bool bAdmin, bool bFailHard, stCallback callback)
@@ -2278,7 +2278,7 @@ void NetworkOPs::gotFetchPack (bool progress, uint32 seq)
mLastFetchPack = 0; mLastFetchPack = 0;
mFetchSeq = seq; // earliest pack we have data on mFetchSeq = seq; // earliest pack we have data on
theApp->getJobQueue ().addJob (jtLEDGER_DATA, "gotFetchPack", theApp->getJobQueue ().addJob (jtLEDGER_DATA, "gotFetchPack",
boost::bind (&InboundLedgers::gotFetchPack, &theApp->getInboundLedgers (), _1)); BIND_TYPE (&InboundLedgers::gotFetchPack, &theApp->getInboundLedgers (), P_1));
} }
void NetworkOPs::missingNodeInLedger (uint32 seq) void NetworkOPs::missingNodeInLedger (uint32 seq)

View File

@@ -112,7 +112,7 @@ void RPCSub::send (const Json::Value& jvObj, bool broadcast)
mSending = true; mSending = true;
WriteLog (lsINFO, RPCSub) << boost::str (boost::format ("callRPC start")); WriteLog (lsINFO, RPCSub) << boost::str (boost::format ("callRPC start"));
boost::thread (boost::bind (&RPCSub::sendThread, this)).detach (); boost::thread (BIND_TYPE (&RPCSub::sendThread, this)).detach ();
} }
} }

View File

@@ -82,7 +82,7 @@ WSDoor* WSDoor::createWSDoor (const std::string& strIp, const int iPort, bool bP
% strIp % strIp
% iPort); % iPort);
wdpResult->mThread = new boost::thread (boost::bind (&WSDoor::startListening, wdpResult)); wdpResult->mThread = new boost::thread (BIND_TYPE (&WSDoor::startListening, wdpResult));
return wdpResult; return wdpResult;
} }

View File

@@ -77,7 +77,7 @@ public:
} }
} }
static void ssend (connection_ptr cpClient, const std::string& strMessage, bool broadcast) static void ssendb (connection_ptr cpClient, const std::string& strMessage, bool broadcast)
{ {
try try
{ {
@@ -93,14 +93,14 @@ public:
void send (connection_ptr cpClient, message_ptr mpMessage) void send (connection_ptr cpClient, message_ptr mpMessage)
{ {
cpClient->get_strand ().post (boost::bind ( cpClient->get_strand ().post (BIND_TYPE (
&WSServerHandler<endpoint_type>::ssend, cpClient, mpMessage)); &WSServerHandler<endpoint_type>::ssend, cpClient, mpMessage));
} }
void send (connection_ptr cpClient, const std::string& strMessage, bool broadcast) void send (connection_ptr cpClient, const std::string& strMessage, bool broadcast)
{ {
cpClient->get_strand ().post (boost::bind ( cpClient->get_strand ().post (BIND_TYPE (
&WSServerHandler<endpoint_type>::ssend, cpClient, strMessage, broadcast)); &WSServerHandler<endpoint_type>::ssendb, cpClient, strMessage, broadcast));
} }
void send (connection_ptr cpClient, const Json::Value& jvObj, bool broadcast) void send (connection_ptr cpClient, const Json::Value& jvObj, bool broadcast)

View File

@@ -362,7 +362,7 @@ void Application::setup ()
mJobQueue.setThreadCount (0, theConfig.RUN_STANDALONE); mJobQueue.setThreadCount (0, theConfig.RUN_STANDALONE);
mSweepTimer.expires_from_now (boost::posix_time::seconds (10)); mSweepTimer.expires_from_now (boost::posix_time::seconds (10));
mSweepTimer.async_wait (boost::bind (&Application::sweep, this)); mSweepTimer.async_wait (BIND_TYPE (&Application::sweep, this));
m_loadManager->startThread (); m_loadManager->startThread ();
@@ -391,7 +391,7 @@ void Application::setup ()
LogPartition::setSeverity (lsDEBUG); LogPartition::setSeverity (lsDEBUG);
} }
boost::thread (boost::bind (runAux, boost::ref (mAuxService))).detach (); boost::thread (BIND_TYPE (runAux, boost::ref (mAuxService))).detach ();
if (!theConfig.RUN_STANDALONE) if (!theConfig.RUN_STANDALONE)
mSNTPClient.init (theConfig.SNTP_SERVERS); mSNTPClient.init (theConfig.SNTP_SERVERS);
@@ -399,16 +399,16 @@ void Application::setup ()
// //
// Construct databases. // Construct databases.
// //
boost::thread t1 (boost::bind (&InitDB, &mRpcDB, "rpc.db", RpcDBInit, RpcDBCount)); boost::thread t1 (BIND_TYPE (&InitDB, &mRpcDB, "rpc.db", RpcDBInit, RpcDBCount));
boost::thread t2 (boost::bind (&InitDB, &mTxnDB, "transaction.db", TxnDBInit, TxnDBCount)); boost::thread t2 (BIND_TYPE (&InitDB, &mTxnDB, "transaction.db", TxnDBInit, TxnDBCount));
boost::thread t3 (boost::bind (&InitDB, &mLedgerDB, "ledger.db", LedgerDBInit, LedgerDBCount)); boost::thread t3 (BIND_TYPE (&InitDB, &mLedgerDB, "ledger.db", LedgerDBInit, LedgerDBCount));
t1.join (); t1.join ();
t2.join (); t2.join ();
t3.join (); t3.join ();
boost::thread t4 (boost::bind (&InitDB, &mWalletDB, "wallet.db", WalletDBInit, WalletDBCount)); boost::thread t4 (BIND_TYPE (&InitDB, &mWalletDB, "wallet.db", WalletDBInit, WalletDBCount));
boost::thread t6 (boost::bind (&InitDB, &mNetNodeDB, "netnode.db", NetNodeDBInit, NetNodeDBCount)); boost::thread t6 (BIND_TYPE (&InitDB, &mNetNodeDB, "netnode.db", NetNodeDBInit, NetNodeDBCount));
boost::thread t7 (boost::bind (&InitDB, &mPathFindDB, "pathfind.db", PathFindDBInit, PathFindDBCount)); boost::thread t7 (BIND_TYPE (&InitDB, &mPathFindDB, "pathfind.db", PathFindDBInit, PathFindDBCount));
t4.join (); t4.join ();
t6.join (); t6.join ();
t7.join (); t7.join ();
@@ -440,7 +440,7 @@ void Application::setup ()
else else
{ {
WriteLog (lsINFO, Application) << "SQLite used for nodes"; WriteLog (lsINFO, Application) << "SQLite used for nodes";
boost::thread t5 (boost::bind (&InitDB, &mHashNodeDB, "hashnode.db", HashNodeDBInit, HashNodeDBCount)); boost::thread t5 (BIND_TYPE (&InitDB, &mHashNodeDB, "hashnode.db", HashNodeDBInit, HashNodeDBCount));
t5.join (); t5.join ();
} }
@@ -638,7 +638,7 @@ void Application::run ()
{ {
if (theConfig.NODE_SIZE >= 2) if (theConfig.NODE_SIZE >= 2)
{ {
boost::thread (boost::bind (runIO, boost::ref (mIOService))).detach (); boost::thread (BIND_TYPE (runIO, boost::ref (mIOService))).detach ();
} }
if (!theConfig.RUN_STANDALONE) if (!theConfig.RUN_STANDALONE)
@@ -688,7 +688,7 @@ void Application::sweep ()
mNetOps.sweepFetchPack (); mNetOps.sweepFetchPack ();
// VFALCO NOTE does the call to sweep() happen on another thread? // VFALCO NOTE does the call to sweep() happen on another thread?
mSweepTimer.expires_from_now (boost::posix_time::seconds (theConfig.getSize (siSweepInterval))); mSweepTimer.expires_from_now (boost::posix_time::seconds (theConfig.getSize (siSweepInterval)));
mSweepTimer.async_wait (boost::bind (&Application::sweep, this)); mSweepTimer.async_wait (BIND_TYPE (&Application::sweep, this));
} }
Application::~Application () Application::~Application ()

View File

@@ -972,7 +972,7 @@ void LedgerConsensus::beginAccept (bool synchronous)
accept (consensusSet, LoadEvent::pointer ()); accept (consensusSet, LoadEvent::pointer ());
else else
{ {
theApp->getIOService ().post (boost::bind (&LedgerConsensus::accept, shared_from_this (), consensusSet, theApp->getIOService ().post (BIND_TYPE (&LedgerConsensus::accept, shared_from_this (), consensusSet,
theApp->getJobQueue ().getLoadEvent (jtACCEPTLEDGER, "LedgerConsensus::beginAccept"))); theApp->getJobQueue ().getLoadEvent (jtACCEPTLEDGER, "LedgerConsensus::beginAccept")));
} }
} }

View File

@@ -255,9 +255,13 @@ void PeerImp::setIpPort (const std::string& strIP, int iPort)
void PeerImp::detach (const char* rsn, bool onIOStrand) void PeerImp::detach (const char* rsn, bool onIOStrand)
{ {
// VFALCO NOTE So essentially, detach() is really two different functions
// depending on the value of onIOStrand.
// TODO Clean this up.
//
if (!onIOStrand) if (!onIOStrand)
{ {
mIOStrand.post (boost::bind (&Peer::detach, shared_from_this (), rsn, true)); mIOStrand.post (BIND_TYPE (&Peer::detach, shared_from_this (), rsn, true));
return; return;
} }
@@ -521,7 +525,7 @@ void PeerImp::sendPacket (const PackedMessage::pointer& packet, bool onStrand)
{ {
if (!onStrand) if (!onStrand)
{ {
mIOStrand.post (boost::bind (&Peer::sendPacket, shared_from_this (), packet, true)); mIOStrand.post (BIND_TYPE (&Peer::sendPacket, shared_from_this (), packet, true));
return; return;
} }

View File

@@ -329,7 +329,7 @@ void Peers::policyEnforce ()
// Schedule next enforcement. // Schedule next enforcement.
mPolicyTimer.expires_at (boost::posix_time::second_clock::universal_time () + boost::posix_time::seconds (POLICY_INTERVAL_SECONDS)); mPolicyTimer.expires_at (boost::posix_time::second_clock::universal_time () + boost::posix_time::seconds (POLICY_INTERVAL_SECONDS));
mPolicyTimer.async_wait (boost::bind (&Peers::policyHandler, this, _1)); mPolicyTimer.async_wait (BIND_TYPE (&Peers::policyHandler, this, P_1));
} }
void Peers::policyHandler (const boost::system::error_code& ecResult) void Peers::policyHandler (const boost::system::error_code& ecResult)
@@ -856,7 +856,7 @@ void Peers::scanRefresh ()
// % strIpPort % tpNext % (tpNext-tpNow).total_seconds()); // % strIpPort % tpNext % (tpNext-tpNow).total_seconds());
mScanTimer.expires_at (tpNext); mScanTimer.expires_at (tpNext);
mScanTimer.async_wait (boost::bind (&Peers::scanHandler, this, _1)); mScanTimer.async_wait (BIND_TYPE (&Peers::scanHandler, this, P_1));
} }
} }
} }

View File

@@ -290,9 +290,9 @@ void SqliteDatabase::doHook (const char* db, int pages)
} }
if (mWalQ) if (mWalQ)
mWalQ->addJob (jtWAL, std::string ("WAL:") + mHost, boost::bind (&SqliteDatabase::runWal, this)); mWalQ->addJob (jtWAL, std::string ("WAL:") + mHost, BIND_TYPE (&SqliteDatabase::runWal, this));
else else
boost::thread (boost::bind (&SqliteDatabase::runWal, this)).detach (); boost::thread (BIND_TYPE (&SqliteDatabase::runWal, this)).detach ();
} }
void SqliteDatabase::runWal () void SqliteDatabase::runWal ()

View File

@@ -39,7 +39,7 @@ void TransactionAcquire::done ()
map = mMap; map = mMap;
} }
theApp->getIOService ().post (boost::bind (&TACompletionHandler, mHash, map)); theApp->getIOService ().post (BIND_TYPE (&TACompletionHandler, mHash, map));
} }
void TransactionAcquire::onTimer (bool progress) void TransactionAcquire::onTimer (bool progress)

View File

@@ -725,7 +725,7 @@ void UniqueNodeList::scoreNext (bool bNow)
// WriteLog (lsTRACE, UniqueNodeList) << str(boost::format("scoreNext: @%s") % mtpScoreNext); // WriteLog (lsTRACE, UniqueNodeList) << str(boost::format("scoreNext: @%s") % mtpScoreNext);
mdtScoreTimer.expires_at (mtpScoreNext); mdtScoreTimer.expires_at (mtpScoreNext);
mdtScoreTimer.async_wait (boost::bind (&UniqueNodeList::scoreTimerHandler, this, _1)); mdtScoreTimer.async_wait (BIND_TYPE (&UniqueNodeList::scoreTimerHandler, this, P_1));
} }
} }
@@ -971,7 +971,7 @@ void UniqueNodeList::getIpsUrl (const RippleAddress& naNodePublic, Section secSi
strPath, strPath,
NODE_FILE_BYTES_MAX, NODE_FILE_BYTES_MAX,
boost::posix_time::seconds (NODE_FETCH_SECONDS), boost::posix_time::seconds (NODE_FETCH_SECONDS),
boost::bind (&UniqueNodeList::responseIps, this, strDomain, naNodePublic, _1, _2, _3)); BIND_TYPE (&UniqueNodeList::responseIps, this, strDomain, naNodePublic, P_1, P_2, P_3));
} }
else else
{ {
@@ -1273,7 +1273,7 @@ void UniqueNodeList::fetchNext ()
mtpFetchNext = tpNext; mtpFetchNext = tpNext;
mdtFetchTimer.expires_at (mtpFetchNext); mdtFetchTimer.expires_at (mtpFetchNext);
mdtFetchTimer.async_wait (boost::bind (&UniqueNodeList::fetchTimerHandler, this, _1)); mdtFetchTimer.async_wait (BIND_TYPE (&UniqueNodeList::fetchTimerHandler, this, P_1));
} }
else else
{ {