Pārlūkot izejas kodu

std::bind换回boost::bind,因为很多编译器还不支持c++ 11

tanghai 12 gadi atpakaļ
vecāks
revīzija
197e26995f

+ 8 - 8
Cpp/Platform/Mono/MonoInit.cc

@@ -13,14 +13,14 @@ namespace Egametang {
 MonoInit::MonoInit(const std::string & domainName)
 {
 	domain = mono_jit_init(domainName.c_str());
-}
-
-MonoInit::~MonoInit()
-{
-    mono_jit_cleanup(domain);
-}
-
-void MonoInit::LoadAssembly(const std::string& fileName)
+}
+
+MonoInit::~MonoInit()
+{
+    mono_jit_cleanup(domain);
+}
+
+void MonoInit::LoadAssembly(const std::string& fileName)
 {
 	MonoAssembly* assembly = mono_domain_assembly_open(domain, fileName.c_str());
 	MonoImage* image = mono_assembly_get_image(assembly);

+ 8 - 8
Cpp/Platform/Mono/MonoInit.cs

@@ -1,9 +1,9 @@
-using System;
-
-public class MonoInit
-{
-	public static void Main ()
-	{
-		Console.WriteLine("Hello Mono World");
-	}
+using System;
+
+public class MonoInit
+{
+	public static void Main ()
+	{
+		Console.WriteLine("Hello Mono World");
+	}
 }

+ 2 - 2
Cpp/Platform/Orm/Select.h

@@ -136,7 +136,7 @@ public:
 };
 
 
-}
-
+}
+
  // namespace Egametang
 #endif // ORM_QUERY_H

+ 3 - 3
Cpp/Platform/Rpc/RpcClient.cc

@@ -1,4 +1,4 @@
-#include <functional>
+#include <boost/bind.hpp>
 #include <boost/asio.hpp>
 #include <google/protobuf/message.h>
 #include <google/protobuf/descriptor.h>
@@ -16,8 +16,8 @@ RpcClient::RpcClient(boost::asio::io_service& ioService, std::string host, int p
 	address.from_string(host);
 	boost::asio::ip::tcp::endpoint endpoint(address, port);
 	socket.async_connect(endpoint,
-			std::bind(&RpcClient::OnAsyncConnect, this,
-					std::placeholders::_1));
+			boost::bind(&RpcClient::OnAsyncConnect, this,
+					boost::asio::placeholders::error));
 }
 
 RpcClient::~RpcClient()

+ 6 - 6
Cpp/Platform/Rpc/RpcClientTest.cc

@@ -29,8 +29,8 @@ public:
 		acceptor.bind(endpoint);
 		acceptor.listen();
 		acceptor.async_accept(socket,
-				std::bind(&RpcServerTest::OnAsyncAccept, this,
-						std::placeholders::_1));
+				boost::bind(&RpcServerTest::OnAsyncAccept, this,
+						boost::asio::placeholders::error));
 	}
 	~RpcServerTest()
 	{
@@ -93,10 +93,10 @@ TEST_F(RpcClientTest, Echo)
 	EchoService_Stub service(client.get());
 
 	boost::threadpool::fifo_pool threadPool(2);
-	threadPool.schedule(std::bind(&IOServiceRun, &ioServer));
+	threadPool.schedule(boost::bind(&IOServiceRun, &ioServer));
 
 	boost::this_thread::sleep(boost::posix_time::milliseconds(500));
-	threadPool.schedule(std::bind(&IOServiceRun, &ioClient));
+	threadPool.schedule(boost::bind(&IOServiceRun, &ioClient));
 
 	EchoRequest request;
 	request.set_num(100);
@@ -109,8 +109,8 @@ TEST_F(RpcClientTest, Echo)
 	barrier.Wait();
 
 	// 加入任务队列,等client和server stop,io_service才stop
-	ioClient.post(std::bind(&boost::asio::io_service::stop, &ioClient));
-	ioServer.post(std::bind(&boost::asio::io_service::stop, &ioServer));
+	ioClient.post(boost::bind(&boost::asio::io_service::stop, &ioClient));
+	ioServer.post(boost::bind(&boost::asio::io_service::stop, &ioServer));
 	ASSERT_EQ(100, response.num());
 }
 

+ 9 - 9
Cpp/Platform/Rpc/RpcCommunicator.cc

@@ -1,5 +1,5 @@
-#include <functional>
 #include <boost/asio.hpp>
+#include <boost/bind.hpp>
 #include <boost/lexical_cast.hpp>
 #include "Rpc/RpcCommunicator.h"
 
@@ -29,8 +29,8 @@ void RpcCommunicator::RecvMeta(RpcMetaPtr meta, StringPtr message)
 {
 	boost::asio::async_read(socket,
 			boost::asio::buffer(reinterpret_cast<char*>(meta.get()), sizeof(*meta)),
-			std::bind(&RpcCommunicator::RecvMessage, this,
-					meta, message, std::placeholders::_1));
+					boost::bind(&RpcCommunicator::RecvMessage, this,
+							meta, message, boost::asio::placeholders::error));
 }
 
 void RpcCommunicator::RecvMessage(RpcMetaPtr meta, StringPtr message,
@@ -44,8 +44,8 @@ void RpcCommunicator::RecvMessage(RpcMetaPtr meta, StringPtr message,
 	message->resize(meta->size, 0);
 	boost::asio::async_read(socket,
 			boost::asio::buffer(reinterpret_cast<char*>(&message->at(0)), meta->size),
-			std::bind(&RpcCommunicator::RecvDone, this,
-					meta, message, std::placeholders::_1));
+			boost::bind(&RpcCommunicator::RecvDone, this,
+					meta, message, boost::asio::placeholders::error));
 }
 
 void RpcCommunicator::RecvDone(RpcMetaPtr meta, StringPtr message,
@@ -68,8 +68,8 @@ void RpcCommunicator::SendMeta(RpcMetaPtr meta, StringPtr message)
 {
 	boost::asio::async_write(socket,
 			boost::asio::buffer(reinterpret_cast<char*>(meta.get()), sizeof(*meta)),
-			std::bind(&RpcCommunicator::SendMessage, this,
-					meta, message, std::placeholders::_1));
+			boost::bind(&RpcCommunicator::SendMessage, this,
+					meta, message, boost::asio::placeholders::error));
 }
 
 void RpcCommunicator::SendMessage(RpcMetaPtr meta, StringPtr message,
@@ -81,8 +81,8 @@ void RpcCommunicator::SendMessage(RpcMetaPtr meta, StringPtr message,
 		return;
 	}
 	boost::asio::async_write(socket, boost::asio::buffer(*message),
-			std::bind(&RpcCommunicator::SendDone, this,
-					meta, message, std::placeholders::_1));
+			boost::bind(&RpcCommunicator::SendDone, this,
+					meta, message, boost::asio::placeholders::error));
 }
 
 void RpcCommunicator::SendDone(RpcMetaPtr meta, StringPtr message,

+ 8 - 8
Cpp/Platform/Rpc/RpcCommunicatorTest.cc

@@ -30,8 +30,8 @@ public:
 		acceptor.bind(endpoint);
 		acceptor.listen();
 		acceptor.async_accept(socket,
-				std::bind(&RpcServerTest::OnAsyncAccept, this,
-						std::placeholders::_1));
+				boost::bind(&RpcServerTest::OnAsyncAccept, this,
+						boost::asio::placeholders::error));
 	}
 
 	void OnAsyncAccept(const boost::system::error_code& err)
@@ -89,8 +89,8 @@ public:
 		address.from_string("127.0.0.1");
 		boost::asio::ip::tcp::endpoint endpoint(address, port);
 		socket.async_connect(endpoint,
-				std::bind(&RpcClientTest::OnAsyncConnect, this,
-						std::placeholders::_1));
+				boost::bind(&RpcClientTest::OnAsyncConnect, this,
+						boost::asio::placeholders::error));
 	}
 
 	void Start()
@@ -144,15 +144,15 @@ TEST_F(RpcCommunicatorTest, SendAndRecvString)
 	RpcClientTest rpcClient(ioClient, globalPort, barrier);
 
 	boost::threadpool::fifo_pool threadPool(2);
-	threadPool.schedule(std::bind(&RpcServerTest::Start, &rpcServer));
+	threadPool.schedule(boost::bind(&RpcServerTest::Start, &rpcServer));
 
 	boost::this_thread::sleep(boost::posix_time::milliseconds(500));
-	threadPool.schedule(std::bind(&RpcClientTest::Start, &rpcClient));
+	threadPool.schedule(boost::bind(&RpcClientTest::Start, &rpcClient));
 	barrier.Wait();
 	threadPool.wait();
 
-	ioClient.post(std::bind(&boost::asio::io_service::stop, &ioClient));
-	ioServer.post(std::bind(&boost::asio::io_service::stop, &ioServer));
+	ioClient.post(boost::bind(&boost::asio::io_service::stop, &ioClient));
+	ioServer.post(boost::bind(&boost::asio::io_service::stop, &ioServer));
 
 	ASSERT_EQ(std::string("send test rpc communicator string"), rpcServer.recvMessage);
 	ASSERT_EQ(rpcServer.recvMeta.size, rpcServer.recvMessage.size());

+ 7 - 7
Cpp/Platform/Rpc/RpcServer.cc

@@ -1,4 +1,4 @@
-#include <functional>
+#include <boost/bind.hpp>
 #include <memory>
 #include <boost/asio.hpp>
 #include <google/protobuf/service.h>
@@ -26,8 +26,8 @@ RpcServer::RpcServer(boost::asio::io_service& service, int port):
 	acceptor.listen();
 	auto newSession = std::make_shared<RpcSession>(ioService, *this);
 	acceptor.async_accept(newSession->Socket(),
-			std::bind(&RpcServer::OnAsyncAccept, this,
-					newSession, std::placeholders::_1));
+			boost::bind(&RpcServer::OnAsyncAccept, this,
+					newSession, boost::asio::placeholders::error));
 }
 
 RpcServer::~RpcServer()
@@ -46,15 +46,15 @@ void RpcServer::OnAsyncAccept(RpcSessionPtr session, const boost::system::error_
 	sessions.insert(session);
 	auto newSession = std::make_shared<RpcSession>(ioService, *this);
 	acceptor.async_accept(newSession->Socket(),
-			std::bind(&RpcServer::OnAsyncAccept, this,
-					newSession, std::placeholders::_1));
+			boost::bind(&RpcServer::OnAsyncAccept, this,
+					newSession, boost::asio::placeholders::error));
 }
 
 void RpcServer::OnCallMethod(RpcSessionPtr session, ResponseHandlerPtr responseHandler)
 {
 	// 调度到网络线
 	session->Socket().get_io_service().post(
-			std::bind(&ResponseHandler::Run, responseHandler));
+			boost::bind(&ResponseHandler::Run, responseHandler));
 }
 
 void RpcServer::RunService(
@@ -70,7 +70,7 @@ void RpcServer::RunService(
 			this, &RpcServer::OnCallMethod, session, responseHandler);
 
 	threadPool.schedule(
-			std::bind(&google::protobuf::Service::CallMethod, methodInfo->GetService(),
+			boost::bind(&google::protobuf::Service::CallMethod, methodInfo->GetService(),
 					&responseHandler->Method(), (google::protobuf::RpcController*)(nullptr),
 					responseHandler->Request(), responseHandler->Response(),
 					done));

+ 1 - 1
Cpp/Platform/Rpc/RpcServer.h

@@ -1,7 +1,7 @@
 #ifndef RPC_RPCSERVER_H
 #define RPC_RPCSERVER_H
 
-#include <functional>
+#include <boost/bind.hpp>
 #include <unordered_set>
 #include <unordered_map>
 #include <boost/asio.hpp>

+ 1 - 1
Cpp/Platform/Rpc/RpcServerMock.h

@@ -1,7 +1,7 @@
 #ifndef RPC_RPCSERVERMOCK_H
 #define RPC_RPCSERVERMOCK_H
 
-#include <functional>
+#include <boost/bind.hpp>
 #include <unordered_set>
 #include <unordered_map>
 #include <boost/asio.hpp>

+ 5 - 5
Cpp/Platform/Rpc/RpcServerTest.cc

@@ -1,4 +1,4 @@
-#include <functional>
+#include <boost/bind.hpp>
 #include <memory>
 #include <boost/asio.hpp>
 #include <boost/threadpool.hpp>
@@ -71,10 +71,10 @@ TEST_F(RpcServerTest, ClientAndServer)
 	ASSERT_EQ(0U, response.num());
 
 	// server和client分别在两个不同的线程
-	threadPool.schedule(std::bind(&IOServiceRun, &ioServer));
+	threadPool.schedule(boost::bind(&IOServiceRun, &ioServer));
 	// 等待server OK
 	boost::this_thread::sleep(boost::posix_time::milliseconds(100));
-	threadPool.schedule(std::bind(&IOServiceRun, &ioClient));
+	threadPool.schedule(boost::bind(&IOServiceRun, &ioClient));
 
 	CountBarrier barrier;
 	service.Echo(nullptr, &request, &response,
@@ -82,8 +82,8 @@ TEST_F(RpcServerTest, ClientAndServer)
 	barrier.Wait();
 
 	// 加入任务队列,等client和server stop,io_service才stop
-	ioClient.post(std::bind(&boost::asio::io_service::stop, &ioClient));
-	ioServer.post(std::bind(&boost::asio::io_service::stop, &ioServer));
+	ioClient.post(boost::bind(&boost::asio::io_service::stop, &ioClient));
+	ioServer.post(boost::bind(&boost::asio::io_service::stop, &ioServer));
 
 	// 必须主动让client和server stop才能wait线程
 	threadPool.wait();

+ 3 - 4
Cpp/Platform/Rpc/RpcSession.cc

@@ -1,5 +1,5 @@
 #include <memory>
-#include <functional>
+#include <boost/bind.hpp>
 #include "Rpc/RpcSession.h"
 #include "Rpc/RpcServer.h"
 
@@ -18,8 +18,7 @@ void RpcSession::OnRecvMessage(RpcMetaPtr meta, StringPtr message)
 {
 	auto session = shared_from_this();
 	rpcServer.RunService(session, meta, message,
-			std::bind(&RpcSession::SendMeta, session,
-					std::placeholders::_1, std::placeholders::_2));
+			boost::bind(&RpcSession::SendMeta, session, _1, _2));
 
 	// RunService函数里读完就不使用了,可以循环利用
 	RecvMeta(meta, message);
@@ -45,7 +44,7 @@ void RpcSession::Stop()
 	isStopped = true;
 	// 延迟删除,必须等所有的bind执行完成后才能remove,
 	// 否则会出现this指针失效的问题
-	ioService.post(std::bind(&RpcServer::Remove, &rpcServer, shared_from_this()));
+	ioService.post(boost::bind(&RpcServer::Remove, &rpcServer, shared_from_this()));
 }
 
 } // namespace Egametang

+ 1 - 1
Cpp/Platform/Rpc/Typedef.h

@@ -2,7 +2,7 @@
 #define RPC_TYPEDEF_H
 
 #include <memory>
-#include <functional>
+#include <boost/bind.hpp>
 #include "Base/Typedef.h"
 
 namespace Egametang {

+ 1 - 1
Cpp/Platform/Thread/CountBarrierTest.cc

@@ -43,7 +43,7 @@ TEST_F(CountBarrierTest, WaitAndSignal)
 	for (int i = 0; i < 10; ++i)
 	{
 		pool.schedule(
-				std::bind(&CountBarrierTest::Signal,
+				boost::bind(&CountBarrierTest::Signal,
 						this, std::ref(barrier)));
 	}
 	ASSERT_EQ(0, this->count);

+ 2 - 2
Cpp/Platform/Thread/ThreadPoolTest.cc

@@ -1,4 +1,4 @@
-#include <functional>
+#include <boost/bind.hpp>
 #include <boost/threadpool.hpp>
 #include <gtest/gtest.h>
 
@@ -21,7 +21,7 @@ TEST_F(ThreadPoolTest, Test1)
 	std::vector<int> z(100, 0);
 	for (int i = 0; i < 100; ++i)
 	{
-		pool.schedule(std::bind(&Max, x[i], y[i], &z[i]));
+		pool.schedule(boost::bind(&Max, x[i], y[i], &z[i]));
 	}
 	pool.wait();
 	for (int i = 0; i < 100; ++i)

+ 1 - 1
Cpp/ThirdParty/boost/threadpool/size_policies.hpp

@@ -24,7 +24,7 @@
 namespace boost { namespace threadpool
 {
 
-  /*! \brief SizePolicyController which provides no functionality.
+  /*! \brief SizePolicyController which provides no boost/bind.hppity.
   *
   * \param Pool The pool's core type.
   */ 

+ 1 - 1
Cpp/ThirdParty/gmock/gmock-matchers.h

@@ -185,7 +185,7 @@ class StringMatchResultListener : public MatchResultListener {
 };
 
 // An internal class for implementing Matcher<T>, which will derive
-// from it.  We put functionalities common to all Matcher<T>
+// from it.  We put boost/bind.hppities common to all Matcher<T>
 // specializations here to avoid code duplication.
 template <typename T>
 class MatcherBase {

+ 8 - 8
Cpp/ThirdParty/gtest/internal/gtest-port.h

@@ -486,15 +486,15 @@
 // not conform to the TR1 spec, which requires the header to be <tuple>.
 
 #  if !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
-// Until version 4.3.2, gcc has a bug that causes <tr1/functional>,
+// Until version 4.3.2, gcc has a bug that causes <tr1/boost/bind.hpp>,
 // which is #included by <tr1/tuple>, to not compile when RTTI is
-// disabled.  _TR1_FUNCTIONAL is the header guard for
-// <tr1/functional>.  Hence the following #define is a hack to prevent
-// <tr1/functional> from being included.
-#   define _TR1_FUNCTIONAL 1
+// disabled.  _TR1_boost/bind.hpp is the header guard for
+// <tr1/boost/bind.hpp>.  Hence the following #define is a hack to prevent
+// <tr1/boost/bind.hpp> from being included.
+#   define _TR1_boost/bind.hpp 1
 #   include <tr1/tuple>
-#   undef _TR1_FUNCTIONAL  // Allows the user to #include
-                        // <tr1/functional> if he chooses to.
+#   undef _TR1_boost/bind.hpp  // Allows the user to #include
+                        // <tr1/boost/bind.hpp> if he chooses to.
 #  else
 #   include <tr1/tuple>  // NOLINT
 #  endif  // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
@@ -1685,7 +1685,7 @@ const BiggestInt kMaxBiggestInt =
 // is typedef-ed to be unsigned int (unsigned integer made up of 4
 // bytes).
 //
-// Such functionality should belong to STL, but I cannot find it
+// Such boost/bind.hppity should belong to STL, but I cannot find it
 // there.
 //
 // Google Test uses this class in the implementation of floating-point

+ 1 - 1
Cpp/ThirdParty/gtest/internal/gtest-string.h

@@ -67,7 +67,7 @@ namespace internal {
 // NULL and the empty string are considered different.  NULL is less
 // than anything (including the empty string) except itself.
 //
-// This class only provides minimum functionality necessary for
+// This class only provides minimum boost/bind.hppity necessary for
 // implementing Google Test.  We do not intend to implement a full-fledged
 // string class here.
 //

+ 1 - 1
Cpp/ThirdParty/gtest/src/gtest-death-test.cc

@@ -318,7 +318,7 @@ void DeathTest::set_last_death_test_message(const String& message) {
 
 String DeathTest::last_death_test_message_;
 
-// Provides cross platform implementation for some death functionality.
+// Provides cross platform implementation for some death boost/bind.hppity.
 class DeathTestImpl : public DeathTest {
  protected:
   DeathTestImpl(const char* a_statement, const RE* a_regex)

+ 1 - 1
Cpp/ThirdParty/gtest/src/gtest.cc

@@ -2938,7 +2938,7 @@ void TestEventRepeater::Append(TestEventListener *listener) {
   listeners_.push_back(listener);
 }
 
-// TODO(vladl@google.com): Factor the search functionality into Vector::Find.
+// TODO(vladl@google.com): Factor the search boost/bind.hppity into Vector::Find.
 TestEventListener* TestEventRepeater::Release(TestEventListener *listener) {
   for (size_t i = 0; i < listeners_.size(); ++i) {
     if (listeners_[i] == listener) {