Просмотр исходного кода

与C#使用同样的命名style,首字母小写,后面单词的首字母大小

tanghai 14 лет назад
Родитель
Сommit
ed6a31b80a

+ 2 - 2
Cpp/Platform/Python/PythonInitTest.cc

@@ -11,10 +11,10 @@ using namespace boost::python;
 class PythonInitTest: public testing::Test
 {
 protected:
-	PythonInit python_init;
+	PythonInit python;
 
 public:
-	PythonInitTest(): python_init()
+	PythonInitTest(): python()
 	{
 	}
 

+ 10 - 10
Cpp/Platform/Python/PythonInterpreter.cc

@@ -7,40 +7,40 @@
 namespace Egametang {
 
 PythonInterpreter::PythonInterpreter():
-		python_init()
+		python()
 {
-	main_ns = boost::python::import("__main__").attr("__dict__");
+	mainNS = boost::python::import("__main__").attr("__dict__");
 }
 
 void PythonInterpreter::ImportPath(std::string path)
 {
-	python_paths.insert(path);
+	paths.insert(path);
 }
 
 void PythonInterpreter::ImportModule(std::string module)
 {
-	python_modules.insert(module);
+	modules.insert(module);
 }
 
 bool PythonInterpreter::GetExecString(const std::string& main_fun, std::string& exec_string)
 {
 	exec_string = "import sys\n";
-	if (python_paths.size() == 0)
+	if (paths.size() == 0)
 	{
 		LOG(WARNING) << "no python path";
 		return false;
 	}
-	foreach (std::string path, python_paths)
+	foreach (std::string path, paths)
 	{
 		exec_string += boost::str(boost::format("sys.path.append('%1%')\n") % path);
 	}
 
-	if (python_modules.size() == 0)
+	if (modules.size() == 0)
 	{
 		LOG(WARNING) << "no python module";
 		return false;
 	}
-	foreach (std::string module, python_modules)
+	foreach (std::string module, modules)
 	{
 		exec_string += boost::str(boost::format("import %1%\n") % module);
 	}
@@ -60,12 +60,12 @@ void PythonInterpreter::Execute(std::string main_fun)
 
 	try
 	{
-		boost::python::exec(exec_string.c_str(), main_ns);
+		boost::python::exec(exec_string.c_str(), mainNS);
 	}
 	catch (...)
 	{
 		LOG(ERROR) << "python execute error";
-		python_init.PrintError();
+		python.PrintError();
 	}
 }
 

+ 5 - 8
Cpp/Platform/Python/PythonInterpreter.h

@@ -12,13 +12,10 @@ namespace Egametang {
 class PythonInterpreter: private boost::noncopyable
 {
 private:
-	PythonInit python_init;
-
-	boost::python::object main_ns;
-
-	boost::unordered_set<std::string> python_paths;
-
-	boost::unordered_set<std::string> python_modules;
+	PythonInit python;
+	boost::python::object mainNS;
+	boost::unordered_set<std::string> paths;
+	boost::unordered_set<std::string> modules;
 
 private:
 	bool GetExecString(const std::string& main_fun, std::string& exec_string);
@@ -33,7 +30,7 @@ public:
 	template <typename T>
 	void RegisterObjectPtr(std::string name, boost::shared_ptr<T> object_ptr)
 	{
-		main_ns[name.c_str()] = object_ptr;
+		mainNS[name.c_str()] = object_ptr;
 	}
 
 	void Execute(std::string main_fun);

+ 6 - 6
Cpp/Platform/Rpc/MethodInfo.h

@@ -10,15 +10,15 @@ namespace Egametang {
 struct MethodInfo
 {
 	RpcServicePtr service;
-	const google::protobuf::MethodDescriptor* method_descriptor;
-	const google::protobuf::Message* request_prototype;
-	const google::protobuf::Message* response_prototype;
+	const google::protobuf::MethodDescriptor* methodDescriptor;
+	const google::protobuf::Message* requestPrototype;
+	const google::protobuf::Message* responsePrototype;
 
 	MethodInfo(RpcServicePtr service, const google::protobuf::MethodDescriptor* method_descriptor):
-		service(service), method_descriptor(method_descriptor)
+		service(service), methodDescriptor(method_descriptor)
 	{
-		request_prototype = &service->GetRequestPrototype(method_descriptor);
-		response_prototype = &service->GetResponsePrototype(method_descriptor);
+		requestPrototype = &service->GetRequestPrototype(method_descriptor);
+		responsePrototype = &service->GetResponsePrototype(method_descriptor);
 	}
 };
 

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

@@ -5,12 +5,12 @@
 namespace Egametang {
 
 ResponseHandler::ResponseHandler(
-		MethodInfoPtr& method_info, std::size_t id, MessageHandler& message_handler):
-		id(id), message_handler(message_handler)
+		MethodInfoPtr& methodInfo, std::size_t id, MessageHandler& messageHandler):
+		id(id), messageHandler(messageHandler)
 {
-	method = method_info->method_descriptor;
-	request = method_info->request_prototype->New();
-	response = method_info->response_prototype->New();
+	method = methodInfo->methodDescriptor;
+	request = methodInfo->requestPrototype->New();
+	response = methodInfo->responsePrototype->New();
 }
 
 ResponseHandler::~ResponseHandler()
@@ -41,7 +41,7 @@ void ResponseHandler::Run()
 	response->SerializeToString(message.get());
 	meta->id = id;
 	meta->size = message->size();
-	message_handler(meta, message);
+	messageHandler(meta, message);
 }
 
 } // namespace Egametang

+ 2 - 3
Cpp/Platform/Rpc/ResponseHandler.h

@@ -12,15 +12,14 @@ namespace Egametang {
 class ResponseHandler
 {
 private:
-
 	const google::protobuf::MethodDescriptor* method;
 	google::protobuf::Message* request;
 	google::protobuf::Message* response;
 	std::size_t id;
-	MessageHandler message_handler;
+	MessageHandler messageHandler;
 
 public:
-	ResponseHandler(MethodInfoPtr& method_info, std::size_t id, MessageHandler& send_message);
+	ResponseHandler(MethodInfoPtr& method_info, std::size_t id, MessageHandler& sendMessage);
 
 	~ResponseHandler();
 

+ 14 - 14
Cpp/Platform/Rpc/RpcChannel.cc

@@ -9,8 +9,8 @@
 
 namespace Egametang {
 
-RpcChannel::RpcChannel(boost::asio::io_service& io_service, std::string host, int port):
-		RpcCommunicator(io_service), id(0)
+RpcChannel::RpcChannel(boost::asio::io_service& ioService, std::string host, int port):
+		RpcCommunicator(ioService), id(0)
 {
 	// another thread?
 	boost::asio::ip::address address;
@@ -32,24 +32,24 @@ void RpcChannel::OnAsyncConnect(const boost::system::error_code& err)
 		LOG(ERROR) << "async connect failed: " << err.message();
 		return;
 	}
-	RpcMetaPtr recv_meta(new RpcMeta());
-	StringPtr recv_message(new std::string);
-	RecvMeta(recv_meta, recv_message);
+	RpcMetaPtr recvMeta(new RpcMeta());
+	StringPtr recvMessage(new std::string);
+	RecvMeta(recvMeta, recvMessage);
 }
 
 void RpcChannel::OnRecvMessage(RpcMetaPtr meta, StringPtr message)
 {
-	RequestHandlerPtr request_handler = request_handlers[meta->id];
-	request_handlers.erase(meta->id);
+	RequestHandlerPtr requestHandler = requestHandlers[meta->id];
+	requestHandlers.erase(meta->id);
 
-	request_handler->Response()->ParseFromString(*message);
+	requestHandler->Response()->ParseFromString(*message);
 
 	// meta和message可以循环利用
 	RecvMeta(meta, message);
 	// 回调放在函数最后.如果RecvMeta()放在回调之后,
 	// 另外线程可能让io_service stop,导致RecvMeta还未跑完
 	// 网络就终止了
-	request_handler->Run();
+	requestHandler->Run();
 }
 
 void RpcChannel::OnSendMessage(RpcMetaPtr meta, StringPtr message)
@@ -58,11 +58,11 @@ void RpcChannel::OnSendMessage(RpcMetaPtr meta, StringPtr message)
 
 void RpcChannel::Stop()
 {
-	if (is_stopped)
+	if (isStopped)
 	{
 		return;
 	}
-	is_stopped = true;
+	isStopped = true;
 	socket.close();
 }
 
@@ -74,16 +74,16 @@ void RpcChannel::CallMethod(
 		google::protobuf::Closure* done)
 {
 	RequestHandlerPtr request_handler(new RequestHandler(response, done));
-	request_handlers[++id] = request_handler;
+	requestHandlers[++id] = request_handler;
 
-	boost::hash<std::string> string_hash;
+	boost::hash<std::string> stringHash;
 
 	StringPtr message(new std::string);
 	request->SerializePartialToString(message.get());
 	RpcMetaPtr meta(new RpcMeta());
 	meta->size = message->size();
 	meta->id = id;
-	meta->method = string_hash(method->full_name());
+	meta->method = stringHash(method->full_name());
 	SendMeta(meta, message);
 }
 

+ 2 - 2
Cpp/Platform/Rpc/RpcChannel.h

@@ -21,8 +21,8 @@ private:
 	typedef boost::unordered_map<std::size_t, RequestHandlerPtr> RequestHandlerMap;
 
 	std::size_t id;
-	RequestHandlerMap request_handlers;
-	bool is_stopped;
+	RequestHandlerMap requestHandlers;
+	bool isStopped;
 
 	void OnAsyncConnect(const boost::system::error_code& err);
 

+ 22 - 22
Cpp/Platform/Rpc/RpcChannelTest.cc

@@ -17,8 +17,8 @@ public:
 	boost::asio::ip::tcp::acceptor acceptor;
 
 public:
-	RpcServerTest(boost::asio::io_service& io_service, int port, CountBarrier& barrier):
-		RpcCommunicator(io_service), acceptor(io_service),
+	RpcServerTest(boost::asio::io_service& ioService, int port, CountBarrier& barrier):
+		RpcCommunicator(ioService), acceptor(ioService),
 		barrier(barrier), num(0)
 	{
 		boost::asio::ip::address address;
@@ -63,13 +63,13 @@ public:
 		EchoResponse response;
 		response.set_num(num);
 
-		StringPtr response_message(new std::string);
-		response.SerializeToString(response_message.get());
-		VLOG(3) << "response message: " << response_message->size();
-		RpcMetaPtr response_meta(new RpcMeta());
-		response_meta->id = meta->id;
-		response_meta->size = response_message->size();
-		SendMeta(response_meta, response_message);
+		StringPtr responseMessage(new std::string);
+		response.SerializeToString(responseMessage.get());
+		VLOG(3) << "response message: " << responseMessage->size();
+		RpcMetaPtr responseMeta(new RpcMeta());
+		responseMeta->id = meta->id;
+		responseMeta->size = responseMessage->size();
+		SendMeta(responseMeta, responseMessage);
 	}
 	virtual void OnSendMessage(RpcMetaPtr meta, StringPtr message)
 	{
@@ -91,24 +91,24 @@ public:
 	}
 };
 
-static void IOServiceRun(boost::asio::io_service* io_service)
+static void IOServiceRun(boost::asio::io_service* ioService)
 {
-	io_service->run();
+	ioService->run();
 }
 
 TEST_F(RpcChannelTest, Echo)
 {
-	boost::asio::io_service io_server;
-	boost::asio::io_service io_client;
+	boost::asio::io_service ioServer;
+	boost::asio::io_service ioClient;
 
 	CountBarrier barrier(2);
-	RpcServerTest server(io_server, port, barrier);
-	RpcChannelPtr channel(new RpcChannel(io_client, "127.0.0.1", port));
+	RpcServerTest server(ioServer, port, barrier);
+	RpcChannelPtr channel(new RpcChannel(ioClient, "127.0.0.1", port));
 	EchoService_Stub service(channel.get());
-	
-	ThreadPool thread_pool(2);
-	thread_pool.Schedule(boost::bind(&IOServiceRun, &io_server));
-	thread_pool.Schedule(boost::bind(&IOServiceRun, &io_client));
+
+	ThreadPool threadPool(2);
+	threadPool.Schedule(boost::bind(&IOServiceRun, &ioServer));
+	threadPool.Schedule(boost::bind(&IOServiceRun, &ioClient));
 
 	EchoRequest request;
 	request.set_num(100);
@@ -121,10 +121,10 @@ TEST_F(RpcChannelTest, Echo)
 	barrier.Wait();
 	channel->Stop();
 	server.Stop();
-	io_server.stop();
-	io_client.stop();
+	ioServer.stop();
+	ioClient.stop();
 	// rpc_channel是个无限循环的操作, 必须主动让channel和server stop才能wait线程
-	thread_pool.Wait();
+	threadPool.Wait();
 
 	ASSERT_EQ(100, response.num());
 }

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

@@ -7,7 +7,7 @@
 namespace Egametang {
 
 RpcCommunicator::RpcCommunicator(boost::asio::io_service& service):
-		io_service(service), socket(service)
+		ioService(service), socket(service)
 {
 }
 

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

@@ -37,7 +37,7 @@ struct RpcMeta
 class RpcCommunicator: public boost::noncopyable
 {
 private:
-	boost::asio::io_service& io_service;
+	boost::asio::io_service& ioService;
 	boost::asio::ip::tcp::socket socket;
 
 public:

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

@@ -15,8 +15,8 @@ class RpcServerTest: public RpcCommunicator
 {
 public:
 	CountBarrier& barrier;
-	std::string recv_message;
-	RpcMeta recv_meta;
+	std::string recvMessage;
+	RpcMeta recvMeta;
 	boost::asio::ip::tcp::acceptor acceptor;
 
 public:
@@ -52,7 +52,7 @@ public:
 	void Start()
 	{
 		VLOG(2) << "Start Server";
-		io_service.run();
+		ioService.run();
 	}
 
 	void Stop()
@@ -64,8 +64,8 @@ public:
 	virtual void OnRecvMessage(RpcMetaPtr meta, StringPtr message)
 	{
 		VLOG(2) << "Server Recv string: " << *message;
-		recv_message = *message;
-		recv_meta = *meta;
+		recvMessage = *message;
+		recvMeta = *meta;
 
 		boost::hash<std::string> string_hash;
 
@@ -85,14 +85,14 @@ public:
 class RpcClientTest: public RpcCommunicator
 {
 public:
-	CountBarrier& barrier_;
-	std::string recv_string_;
-	RpcMeta meta_;
+	CountBarrier& barrier;
+	std::string recvString;
+	RpcMeta recvMeta;
 
 public:
 	RpcClientTest(boost::asio::io_service& io_service, int port,
 			CountBarrier& barrier):
-		RpcCommunicator(io_service), barrier_(barrier)
+		RpcCommunicator(io_service), barrier(barrier)
 	{
 		boost::asio::ip::address address;
 		address.from_string("127.0.0.1");
@@ -105,7 +105,7 @@ public:
 	void Start()
 	{
 		VLOG(2) << "Start Client";
-		io_service.run();
+		ioService.run();
 	}
 
 	void Stop()
@@ -136,9 +136,9 @@ public:
 	virtual void OnRecvMessage(RpcMetaPtr meta, StringPtr message)
 	{
 		VLOG(2) << "Client Recv string: " << *message;
-		recv_string_ = *message;
-		meta_ = *meta;
-		barrier_.Signal();
+		recvString = *message;
+		recvMeta = *meta;
+		barrier.Signal();
 	}
 
 	virtual void OnSendMessage()
@@ -149,17 +149,17 @@ public:
 class RpcCommunicatorTest: public testing::Test
 {
 protected:
-	boost::asio::io_service io_server;
-	boost::asio::io_service io_client;
-	CountBarrier barrier_;
-	RpcServerTest rpc_server;
-	RpcClientTest rpc_client;
+	boost::asio::io_service ioServer;
+	boost::asio::io_service ioClient;
+	CountBarrier barrier;
+	RpcServerTest rpcServer;
+	RpcClientTest rpcClient;
 
 public:
 	RpcCommunicatorTest():
-		io_server(), io_client(),
-		barrier_(2), rpc_server(io_server, global_port, barrier_),
-		rpc_client(io_client, global_port, barrier_)
+		ioServer(), ioClient(),
+		barrier(2), rpcServer(ioServer, global_port, barrier),
+		rpcClient(ioClient, global_port, barrier)
 	{
 	}
 
@@ -172,20 +172,20 @@ public:
 TEST_F(RpcCommunicatorTest, SendAndRecvString)
 {
 	ThreadPool thread_pool(2);
-	thread_pool.Schedule(boost::bind(&RpcServerTest::Start, &rpc_server));
-	thread_pool.Schedule(boost::bind(&RpcClientTest::Start, &rpc_client));
-	barrier_.Wait();
+	thread_pool.Schedule(boost::bind(&RpcServerTest::Start, &rpcServer));
+	thread_pool.Schedule(boost::bind(&RpcClientTest::Start, &rpcClient));
+	barrier.Wait();
 	thread_pool.Wait();
-	rpc_server.Stop();
-	rpc_client.Stop();
+	rpcServer.Stop();
+	rpcClient.Stop();
 
-	ASSERT_EQ(std::string("send test rpc communicator string"), rpc_server.recv_message);
-	ASSERT_EQ(rpc_server.recv_meta.size, rpc_server.recv_message.size());
-	ASSERT_EQ(654321U, rpc_server.recv_meta.method);
+	ASSERT_EQ(std::string("send test rpc communicator string"), rpcServer.recvMessage);
+	ASSERT_EQ(rpcServer.recvMeta.size, rpcServer.recvMessage.size());
+	ASSERT_EQ(654321U, rpcServer.recvMeta.method);
 
-	ASSERT_EQ(std::string("response test rpc communicator string"), rpc_client.recv_string_);
-	ASSERT_EQ(rpc_client.meta_.size, rpc_client.recv_string_.size());
-	ASSERT_EQ(123456U, rpc_client.meta_.method);
+	ASSERT_EQ(std::string("response test rpc communicator string"), rpcClient.recvString);
+	ASSERT_EQ(rpcClient.recvMeta.size, rpcClient.recvString.size());
+	ASSERT_EQ(123456U, rpcClient.recvMeta.method);
 }
 
 } // namespace Egametang

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

@@ -14,8 +14,8 @@
 namespace Egametang {
 
 RpcServer::RpcServer(boost::asio::io_service& service, int port):
-		io_service(service), acceptor(io_service),
-		thread_pool(), sessions(),
+		ioService(service), acceptor(ioService),
+		threadPool(), sessions(),
 		methods()
 {
 	boost::asio::ip::address address;
@@ -25,7 +25,7 @@ RpcServer::RpcServer(boost::asio::io_service& service, int port):
 	acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
 	acceptor.bind(endpoint);
 	acceptor.listen();
-	RpcSessionPtr new_session(new RpcSession(io_service, *this));
+	RpcSessionPtr new_session(new RpcSession(ioService, *this));
 	acceptor.async_accept(new_session->Socket(),
 			boost::bind(&RpcServer::OnAsyncAccept, this,
 					new_session, boost::asio::placeholders::error));
@@ -44,40 +44,40 @@ void RpcServer::OnAsyncAccept(RpcSessionPtr session, const boost::system::error_
 	}
 	session->Start();
 	sessions.insert(session);
-	RpcSessionPtr new_session(new RpcSession(io_service, *this));
+	RpcSessionPtr new_session(new RpcSession(ioService, *this));
 	acceptor.async_accept(new_session->Socket(),
 			boost::bind(&RpcServer::OnAsyncAccept, this,
 					new_session, boost::asio::placeholders::error));
 }
 
-void RpcServer::OnCallMethod(RpcSessionPtr session, ResponseHandlerPtr response_handler)
+void RpcServer::OnCallMethod(RpcSessionPtr session, ResponseHandlerPtr responseHandler)
 {
 	// 调度到网络线程
 	session->Socket().get_io_service().post(
-			boost::bind(&ResponseHandler::Run, response_handler));
+			boost::bind(&ResponseHandler::Run, responseHandler));
 }
 
 void RpcServer::Stop()
 {
-	thread_pool.Wait();
+	threadPool.Wait();
 	acceptor.close();
 	sessions.clear();
 }
 
 void RpcServer::RunService(RpcSessionPtr session, RpcMetaPtr meta,
-		StringPtr message, MessageHandler message_handler)
+		StringPtr message, MessageHandler messageHandler)
 {
 	MethodInfoPtr method_info = methods[meta->method];
 
 	ResponseHandlerPtr response_handler(
-			new ResponseHandler(method_info, meta->id, message_handler));
+			new ResponseHandler(method_info, meta->id, messageHandler));
 	response_handler->Request()->ParseFromString(*message);
 
 	google::protobuf::Closure* done = google::protobuf::NewCallback(
 			this, &RpcServer::OnCallMethod,
 			session, response_handler);
 
-	thread_pool.Schedule(
+	threadPool.Schedule(
 			boost::bind(&google::protobuf::Service::CallMethod, method_info->service,
 					response_handler->Method(), (google::protobuf::RpcController*)(NULL),
 					response_handler->Request(), response_handler->Response(),

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

@@ -17,21 +17,21 @@ private:
 	typedef boost::unordered_set<RpcSessionPtr> RpcSessionSet;
 	typedef boost::unordered_map<std::size_t, MethodInfoPtr> MethodMap;
 
-	boost::asio::io_service& io_service;
+	boost::asio::io_service& ioService;
 	boost::asio::ip::tcp::acceptor acceptor;
-	ThreadPool thread_pool;
+	ThreadPool threadPool;
 	RpcSessionSet sessions;
 	MethodMap methods;
 
 	void OnAsyncAccept(RpcSessionPtr session, const boost::system::error_code& err);
-	void OnCallMethod(RpcSessionPtr session, ResponseHandlerPtr response_handler);
+	void OnCallMethod(RpcSessionPtr session, ResponseHandlerPtr responseHandler);
 
 public:
 	RpcServer(boost::asio::io_service& service, int port);
 	virtual ~RpcServer();
 
 	virtual void RunService(RpcSessionPtr session, RpcMetaPtr meta,
-			StringPtr message, MessageHandler handler);
+			StringPtr message, MessageHandler messageHandler);
 	virtual void Register(RpcServicePtr service);
 	virtual void Remove(RpcSessionPtr& session);
 	virtual void Stop();

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

@@ -34,20 +34,20 @@ public:
 	}
 };
 
-static void IOServiceRun(boost::asio::io_service* io_service)
+static void IOServiceRun(boost::asio::io_service* ioService)
 {
-	io_service->run();
+	ioService->run();
 }
 
 class RpcServerTest: public testing::Test
 {
 protected:
-	boost::asio::io_service io_client;
-	boost::asio::io_service io_server;
+	boost::asio::io_service ioClient;
+	boost::asio::io_service ioServer;
 	int port;
 
 public:
-	RpcServerTest(): io_client(), io_server(), port(10003)
+	RpcServerTest(): ioClient(), ioServer(), port(10003)
 	{
 	}
 
@@ -58,16 +58,16 @@ public:
 
 TEST_F(RpcServerTest, ChannelAndServer)
 {
-	ThreadPool thread_pool(2);
+	ThreadPool threadPool(2);
 
-	RpcServicePtr echo_sevice(new MyEcho);
+	RpcServicePtr echoSevice(new MyEcho);
 
-	RpcServerPtr server(new RpcServer(io_server, port));
+	RpcServerPtr server(new RpcServer(ioServer, port));
 	// 注册service
-	server->Register(echo_sevice);
+	server->Register(echoSevice);
 	ASSERT_EQ(1U, server->methods.size());
 
-	RpcChannelPtr channel(new RpcChannel(io_client, "127.0.0.1", port));
+	RpcChannelPtr channel(new RpcChannel(ioClient, "127.0.0.1", port));
 	EchoService_Stub service(channel.get());
 
 	// 定义消息
@@ -77,8 +77,8 @@ TEST_F(RpcServerTest, ChannelAndServer)
 	ASSERT_EQ(0U, response.num());
 
 	// server和client分别在两个不同的线程
-	thread_pool.Schedule(boost::bind(&IOServiceRun, &io_server));
-	thread_pool.Schedule(boost::bind(&IOServiceRun, &io_client));
+	threadPool.Schedule(boost::bind(&IOServiceRun, &ioServer));
+	threadPool.Schedule(boost::bind(&IOServiceRun, &ioClient));
 
 	CountBarrier barrier;
 	service.Echo(NULL, &request, &response,
@@ -86,15 +86,15 @@ TEST_F(RpcServerTest, ChannelAndServer)
 	barrier.Wait();
 
 	// 加入到io线程
-	io_client.post(boost::bind(&RpcChannel::Stop, channel));
-	io_server.post(boost::bind(&RpcServer::Stop, server));
+	ioClient.post(boost::bind(&RpcChannel::Stop, channel));
+	ioServer.post(boost::bind(&RpcServer::Stop, server));
 
 	// 加入任务队列,等channel和server stop,io_service才stop
-	io_client.post(boost::bind(&boost::asio::io_service::stop, &io_client));
-	io_server.post(boost::bind(&boost::asio::io_service::stop, &io_server));
+	ioClient.post(boost::bind(&boost::asio::io_service::stop, &ioClient));
+	ioServer.post(boost::bind(&boost::asio::io_service::stop, &ioServer));
 
 	// rpc_channel是个无限循环的操作, 必须主动让channel和server stop才能wait线程
-	thread_pool.Wait();
+	threadPool.Wait();
 
 	ASSERT_EQ(100, response.num());
 }

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

@@ -5,8 +5,8 @@
 
 namespace Egametang {
 
-RpcSession::RpcSession(boost::asio::io_service& io_service, RpcServer& server):
-		RpcCommunicator(io_service), rpc_server(server), is_stopped(false)
+RpcSession::RpcSession(boost::asio::io_service& ioService, RpcServer& server):
+		RpcCommunicator(ioService), rpcServer(server), isStopped(false)
 {
 }
 
@@ -18,7 +18,7 @@ RpcSession::~RpcSession()
 void RpcSession::OnRecvMessage(RpcMetaPtr meta, StringPtr message)
 {
 	RpcSessionPtr session = shared_from_this();
-	rpc_server.RunService(session, meta, message,
+	rpcServer.RunService(session, meta, message,
 			boost::bind(&RpcSession::SendMeta, session, _1, _2));
 
 	// 可以循环利用
@@ -38,13 +38,13 @@ void RpcSession::Start()
 
 void RpcSession::Stop()
 {
-	if (is_stopped)
+	if (isStopped)
 	{
 		return;
 	}
-	is_stopped = true;
+	isStopped = true;
 	RpcSessionPtr session = shared_from_this();
-	rpc_server.Remove(session);
+	rpcServer.Remove(session);
 }
 
 } // namespace Egametang

+ 3 - 3
Cpp/Platform/Rpc/RpcSession.h

@@ -14,14 +14,14 @@ class RpcServer;
 class RpcSession: public RpcCommunicator, public boost::enable_shared_from_this<RpcSession>
 {
 private:
-	RpcServer& rpc_server;
-	bool is_stopped;
+	RpcServer& rpcServer;
+	bool isStopped;
 
 	virtual void OnRecvMessage(RpcMetaPtr meta, StringPtr message);
 	virtual void OnSendMessage(RpcMetaPtr meta, StringPtr message);
 
 public:
-	RpcSession(boost::asio::io_service& io_service, RpcServer& server);
+	RpcSession(boost::asio::io_service& ioService, RpcServer& server);
 	~RpcSession();
 	void Start();
 	virtual void Stop();

+ 4 - 4
Cpp/Platform/Rpc/RpcSessionTest.cc

@@ -11,15 +11,15 @@ namespace Egametang {
 class RpcSessionTest: public testing::Test
 {
 protected:
-	boost::asio::io_service io_service;
+	boost::asio::io_service ioService;
 	int port;
-	RpcServerMock mock_server;
+	RpcServerMock mockServer;
 	RpcSession session;
 
 public:
 	RpcSessionTest():
-		io_service(), port(10000),
-		mock_server(io_service, port), session(io_service, mock_server)
+		ioService(), port(10000),
+		mockServer(ioService, port), session(ioService, mockServer)
 	{
 	}
 

+ 6 - 6
Cpp/Platform/Thread/ThreadPool.cc

@@ -4,19 +4,19 @@
 namespace Egametang {
 
 ThreadPool::ThreadPool(int num) :
-	thread_num(num), running(true), work_num(0)
+	threadNum(num), running(true), workNum(0)
 {
 	if (num == 0)
 	{
-		thread_num = boost::thread::hardware_concurrency();
+		threadNum = boost::thread::hardware_concurrency();
 	}
-	for (int i = 0; i < thread_num; ++i)
+	for (int i = 0; i < threadNum; ++i)
 	{
 		ThreadPtr t(new boost::thread(
 				boost::bind(&ThreadPool::Runner, this)));
 		threads.push_back(t);
 		t->detach();
-		++work_num;
+		++workNum;
 	}
 }
 
@@ -29,7 +29,7 @@ void ThreadPool::Wait()
 	boost::mutex::scoped_lock lock(mutex);
 	running = false;
 	cond.notify_all();
-	while (work_num > 0)
+	while (workNum > 0)
 	{
 		done.wait(lock);
 	}
@@ -60,7 +60,7 @@ void ThreadPool::Runner()
 			task();
 		}
 	}
-	if (--work_num == 0)
+	if (--workNum == 0)
 	{
 		done.notify_one();
 	}

+ 2 - 2
Cpp/Platform/Thread/ThreadPool.h

@@ -14,8 +14,8 @@ namespace Egametang {
 class ThreadPool: private boost::noncopyable
 {
 private:
-	int thread_num;
-	boost::detail::atomic_count work_num;
+	int threadNum;
+	boost::detail::atomic_count workNum;
 	volatile bool running;
 	boost::mutex mutex;
 	boost::condition_variable cond;