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

类的成员命去掉末尾的下划线

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

+ 10 - 10
Src/Egametang/Python/PythonInterpreter.cc

@@ -7,40 +7,40 @@
 namespace Egametang {
 
 PythonInterpreter::PythonInterpreter():
-		python_init_()
+		python_init()
 {
-	main_ns_ = boost::python::import("__main__").attr("__dict__");
+	main_ns = boost::python::import("__main__").attr("__dict__");
 }
 
 void PythonInterpreter::ImportPath(std::string path)
 {
-	python_paths_.insert(path);
+	python_paths.insert(path);
 }
 
 void PythonInterpreter::ImportModule(std::string module)
 {
-	python_modules_.insert(module);
+	python_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 (python_paths.size() == 0)
 	{
 		LOG(WARNING) << "no python path";
 		return false;
 	}
-	foreach(std::string path, python_paths_)
+	foreach(std::string path, python_paths)
 	{
 		exec_string += boost::str(boost::format("sys.path.append('%1%')\n") % path);
 	}
 
-	if (python_modules_.size() == 0)
+	if (python_modules.size() == 0)
 	{
 		LOG(WARNING) << "no python module";
 		return false;
 	}
-	foreach(std::string module, python_modules_)
+	foreach(std::string module, python_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(), main_ns);
 	}
 	catch (...)
 	{
 		LOG(ERROR) << "python execute error";
-		python_init_.PrintError();
+		python_init.PrintError();
 	}
 }
 

+ 5 - 5
Src/Egametang/Python/PythonInterpreter.h

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

+ 13 - 13
Src/Egametang/Python/PythonInterpreterTest.cc

@@ -9,10 +9,10 @@ namespace Egametang {
 class PythonInterpreterTest: public testing::Test
 {
 protected:
-	PythonInterpreter interpreter_;
+	PythonInterpreter interpreter;
 
 public:
-	PythonInterpreterTest(): interpreter_()
+	PythonInterpreterTest(): interpreter()
 	{
 	}
 
@@ -24,31 +24,31 @@ public:
 class PersonTest
 {
 private:
-	int guid_;
-	std::string name_;
+	int guid;
+	std::string name;
 
 public:
-	PersonTest(): guid_(0)
+	PersonTest(): guid(0)
 	{
 	}
 	void SetGuid(int guid)
 	{
-		guid_ = guid;
+		this->guid = guid;
 	}
 
 	int Guid() const
 	{
-		return guid_;
+		return guid;
 	}
 
 	void SetName(const std::string& name)
 	{
-		name_ = name;
+		this->name = name;
 	}
 
 	std::string Name() const
 	{
-		return name_;
+		return name;
 	}
 };
 
@@ -68,16 +68,16 @@ BOOST_PYTHON_MODULE(PersonTest)
 TEST_F(PythonInterpreterTest, EnterPythonScript)
 {
 	initPersonTest();
-	interpreter_.ImportPath("../../../Src/Egametang/Python/");
-	interpreter_.ImportModule("PythonInterpreterTest");
+	interpreter.ImportPath("../../../Src/Egametang/Python/");
+	interpreter.ImportModule("PythonInterpreterTest");
 
 	PersonTestPtr person(new PersonTest);
-	interpreter_.RegisterObjectPtr("person", person);
+	interpreter.RegisterObjectPtr("person", person);
 
 	ASSERT_EQ(0, person->Guid());
 
 	// 进到python脚本层设置person的值为2
-	interpreter_.Execute("PythonInterpreterTest.fun(person)");
+	interpreter.Execute("PythonInterpreterTest.fun(person)");
 
 	ASSERT_EQ(2, person->Guid());
 	ASSERT_EQ(std::string("tanghai"), person->Name());

+ 1 - 0
Src/Egametang/Rpc/MethodInfo.h

@@ -12,6 +12,7 @@ struct MethodInfo
 	const google::protobuf::MethodDescriptor* method_descriptor;
 	google::protobuf::Message* request_prototype;
 	google::protobuf::Message* response_prototype;
+
 	MethodInfo(RpcServicePtr service, const google::protobuf::MethodDescriptor* method_descriptor):
 		service(service), method_descriptor(method_descriptor)
 	{

+ 1 - 0
Src/Egametang/Rpc/RequestHandler.h

@@ -11,6 +11,7 @@ class RequestHandler
 private:
 	google::protobuf::Message* response;
 	google::protobuf::Closure* done;
+
 public:
 	RequestHandler(
 			google::protobuf::Message* response,

+ 2 - 0
Src/Egametang/Rpc/ResponseHandler.h

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

+ 6 - 6
Src/Egametang/Rpc/RpcChannel.cc

@@ -10,13 +10,13 @@
 namespace Egametang {
 
 RpcChannel::RpcChannel(boost::asio::io_service& io_service, std::string host, int port):
-		RpcCommunicator(io_service), id_(0)
+		RpcCommunicator(io_service), id(0)
 {
 	// another thread?
 	boost::asio::ip::address address;
 	address.from_string(host);
 	boost::asio::ip::tcp::endpoint endpoint(address, port);
-	socket_.async_connect(endpoint,
+	socket.async_connect(endpoint,
 			boost::bind(&RpcChannel::OnAsyncConnect, this,
 					boost::asio::placeholders::error));
 }
@@ -39,8 +39,8 @@ void RpcChannel::OnAsyncConnect(const boost::system::error_code& err)
 
 void RpcChannel::OnRecvMessage(RpcMetaPtr meta, StringPtr message)
 {
-	RequestHandlerPtr request_handler = request_handlers_[meta->id];
-	request_handlers_.erase(meta->id);
+	RequestHandlerPtr request_handler = request_handlers[meta->id];
+	request_handlers.erase(meta->id);
 
 	request_handler->Response()->ParseFromString(*message);
 
@@ -69,7 +69,7 @@ void RpcChannel::CallMethod(
 		google::protobuf::Closure* done)
 {
 	RequestHandlerPtr request_handler(new RequestHandler(response, done));
-	request_handlers_[++id_] = request_handler;
+	request_handlers[++id] = request_handler;
 
 	boost::hash<std::string> string_hash;
 
@@ -77,7 +77,7 @@ void RpcChannel::CallMethod(
 	request->SerializePartialToString(message.get());
 	RpcMetaPtr meta(new RpcMeta());
 	meta->size = message->size();
-	meta->id = id_;
+	meta->id = id;
 	meta->method = string_hash(method->full_name());
 	SendMeta(meta, message);
 }

+ 2 - 2
Src/Egametang/Rpc/RpcChannel.h

@@ -17,8 +17,8 @@ class RpcChannel: public google::protobuf::RpcChannel, public RpcCommunicator
 private:
 	typedef boost::unordered_map<std::size_t, RequestHandlerPtr> RequestHandlerMap;
 
-	std::size_t id_;
-	RequestHandlerMap request_handlers_;
+	std::size_t id;
+	RequestHandlerMap request_handlers;
 
 	void OnAsyncConnect(const boost::system::error_code& err);
 

+ 15 - 15
Src/Egametang/Rpc/RpcChannelTest.cc

@@ -14,23 +14,23 @@ static int global_port = 10002;
 class RpcServerTest: public RpcCommunicator
 {
 public:
-	CountBarrier& barrier_;
-	int32 num_;
-	boost::asio::ip::tcp::acceptor acceptor_;
+	CountBarrier& barrier;
+	int32 num;
+	boost::asio::ip::tcp::acceptor acceptor;
 
 public:
 	RpcServerTest(boost::asio::io_service& io_service, int port, CountBarrier& barrier):
-		RpcCommunicator(io_service), acceptor_(io_service),
-		barrier_(barrier), num_(0)
+		RpcCommunicator(io_service), acceptor(io_service),
+		barrier(barrier), num(0)
 	{
 		boost::asio::ip::address address;
 		address.from_string("127.0.0.1");
 		boost::asio::ip::tcp::endpoint endpoint(address, port);
-		acceptor_.open(endpoint.protocol());
-		acceptor_.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
-		acceptor_.bind(endpoint);
-		acceptor_.listen();
-		acceptor_.async_accept(socket_,
+		acceptor.open(endpoint.protocol());
+		acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
+		acceptor.bind(endpoint);
+		acceptor.listen();
+		acceptor.async_accept(socket,
 				boost::bind(&RpcServerTest::OnAsyncAccept, this,
 						boost::asio::placeholders::error));
 	}
@@ -49,8 +49,8 @@ public:
 
 	void Stop()
 	{
-		acceptor_.close();
-		socket_.close();
+		acceptor.close();
+		socket.close();
 	}
 
 	virtual void OnRecvMessage(RpcMetaPtr meta, StringPtr message)
@@ -59,11 +59,11 @@ public:
 		EchoRequest request;
 		request.ParseFromString(*message);
 
-		num_ = request.num();
+		num = request.num();
 
 		// 回一个消息
 		EchoResponse response;
-		response.set_num(num_);
+		response.set_num(num);
 
 		StringPtr response_message(new std::string);
 		response.SerializeToString(response_message.get());
@@ -75,7 +75,7 @@ public:
 	}
 	virtual void OnSendMessage(RpcMetaPtr meta, StringPtr message)
 	{
-		barrier_.Signal();
+		barrier.Signal();
 	}
 };
 

+ 7 - 7
Src/Egametang/Rpc/RpcCommunicator.cc

@@ -7,7 +7,7 @@
 namespace Egametang {
 
 RpcCommunicator::RpcCommunicator(boost::asio::io_service& io_service):
-		io_service_(io_service), socket_(io_service)
+		io_service(io_service), socket(io_service)
 {
 }
 
@@ -17,18 +17,18 @@ RpcCommunicator::~RpcCommunicator()
 
 boost::asio::ip::tcp::socket& RpcCommunicator::Socket()
 {
-	return socket_;
+	return socket;
 }
 
 void RpcCommunicator::Stop()
 {
-	socket_.close();
+	socket.close();
 }
 
 
 void RpcCommunicator::RecvMeta(RpcMetaPtr meta, StringPtr message)
 {
-	boost::asio::async_read(socket_,
+	boost::asio::async_read(socket,
 			boost::asio::buffer(reinterpret_cast<char*>(meta.get()), sizeof(*meta)),
 			boost::bind(&RpcCommunicator::RecvMessage, this,
 					meta, message, boost::asio::placeholders::error));
@@ -43,7 +43,7 @@ void RpcCommunicator::RecvMessage(RpcMetaPtr meta, StringPtr message,
 		return;
 	}
 	message->resize(meta->size, '\0');
-	boost::asio::async_read(socket_,
+	boost::asio::async_read(socket,
 			boost::asio::buffer(reinterpret_cast<char*>(&message->at(0)), meta->size),
 			boost::bind(&RpcCommunicator::RecvDone, this,
 					meta, message, boost::asio::placeholders::error));
@@ -68,7 +68,7 @@ void RpcCommunicator::OnRecvMessage(RpcMetaPtr meta, StringPtr message)
 void RpcCommunicator::SendMeta(RpcMetaPtr meta, StringPtr message)
 {
 	CHECK_EQ(meta->size, message->size()) << "meta and message size not match!";
-	boost::asio::async_write(socket_,
+	boost::asio::async_write(socket,
 			boost::asio::buffer(reinterpret_cast<char*>(meta.get()), sizeof(*meta)),
 			boost::bind(&RpcCommunicator::SendMessage, this,
 					meta, message, boost::asio::placeholders::error));
@@ -82,7 +82,7 @@ void RpcCommunicator::SendMessage(RpcMetaPtr meta, StringPtr message,
 		LOG(ERROR) << "send message size failed: " << err.message();
 		return;
 	}
-	boost::asio::async_write(socket_, boost::asio::buffer(*message),
+	boost::asio::async_write(socket, boost::asio::buffer(*message),
 			boost::bind(&RpcCommunicator::SendDone, this,
 					meta, message, boost::asio::placeholders::error));
 }

+ 2 - 2
Src/Egametang/Rpc/RpcCommunicator.h

@@ -37,8 +37,8 @@ struct RpcMeta
 class RpcCommunicator: public boost::noncopyable
 {
 protected:
-	boost::asio::io_service& io_service_;
-	boost::asio::ip::tcp::socket socket_;
+	boost::asio::io_service& io_service;
+	boost::asio::ip::tcp::socket socket;
 
 	explicit RpcCommunicator(boost::asio::io_service& io_service);
 	virtual ~RpcCommunicator();

+ 6 - 6
Src/Egametang/Rpc/RpcCommunicatorTest.cc

@@ -31,7 +31,7 @@ public:
 		acceptor_.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
 		acceptor_.bind(endpoint);
 		acceptor_.listen();
-		acceptor_.async_accept(socket_,
+		acceptor_.async_accept(socket,
 				boost::bind(&RpcServerTest::OnAsyncAccept, this,
 						boost::asio::placeholders::error));
 	}
@@ -52,13 +52,13 @@ public:
 	void Start()
 	{
 		VLOG(2) << "Start Server";
-		io_service_.run();
+		io_service.run();
 	}
 
 	void Stop()
 	{
 		acceptor_.close();
-		socket_.close();
+		socket.close();
 	}
 
 	virtual void OnRecvMessage(RpcMetaPtr meta, StringPtr message)
@@ -97,7 +97,7 @@ public:
 		boost::asio::ip::address address;
 		address.from_string("127.0.0.1");
 		boost::asio::ip::tcp::endpoint endpoint(address, port);
-		socket_.async_connect(endpoint,
+		socket.async_connect(endpoint,
 				boost::bind(&RpcClientTest::OnAsyncConnect, this,
 						boost::asio::placeholders::error));
 	}
@@ -105,12 +105,12 @@ public:
 	void Start()
 	{
 		VLOG(2) << "Start Client";
-		io_service_.run();
+		io_service.run();
 	}
 
 	void Stop()
 	{
-		socket_.close();
+		socket.close();
 	}
 
 	void OnAsyncConnect(const boost::system::error_code& err)

+ 6 - 6
Src/Egametang/Rpc/RpcController.cc

@@ -12,19 +12,19 @@ RpcController::~RpcController()
 
 void RpcController::Reset()
 {
-	failed_ = false;
-	reason_ = "";
-	canceled_ = false;
+	failed = false;
+	reason = "";
+	canceled = false;
 }
 
 bool RpcController::Failed() const
 {
-	return failed_;
+	return failed;
 }
 
 std::string RpcController::ErrorText() const
 {
-	return reason_;
+	return reason;
 }
 
 void RpcController::StartCancel()
@@ -37,7 +37,7 @@ void RpcController::SetFailed(const std::string& reason)
 
 bool RpcController::IsCanceled() const
 {
-	return canceled_;
+	return canceled;
 }
 
 void RpcController::NotifyOnCancel(google::protobuf::Closure *callback)

+ 3 - 3
Src/Egametang/Rpc/RpcController.h

@@ -8,9 +8,9 @@ namespace Egametang {
 class RpcController: public google::protobuf::RpcController
 {
 private:
-	bool failed_;
-	std::string reason_;
-	bool canceled_;
+	bool failed;
+	std::string reason;
+	bool canceled;
 
 public:
 	RpcController();

+ 18 - 18
Src/Egametang/Rpc/RpcServer.cc

@@ -13,24 +13,24 @@
 namespace Egametang {
 
 RpcServer::RpcServer(boost::asio::io_service& io_service, int port):
-		io_service_(io_service), thread_pool_()
+		io_service(io_service), thread_pool()
 {
 	boost::asio::ip::address address;
 	address.from_string("localhost");
 	boost::asio::ip::tcp::endpoint endpoint(address, port);
-	acceptor_.open(endpoint.protocol());
-	acceptor_.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
-	acceptor_.bind(endpoint);
-	acceptor_.listen();
+	acceptor.open(endpoint.protocol());
+	acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
+	acceptor.bind(endpoint);
+	acceptor.listen();
 	RpcSessionPtr new_session(new RpcSession(*this));
-	acceptor_.async_accept(new_session->Socket(),
+	acceptor.async_accept(new_session->Socket(),
 			boost::bind(&RpcServer::OnAsyncAccept, this,
 					new_session, boost::asio::placeholders::error));
 }
 
 boost::asio::io_service& RpcServer::IOService()
 {
-	return io_service_;
+	return io_service;
 }
 
 void RpcServer::OnAsyncAccept(RpcSessionPtr session, const boost::system::error_code& err)
@@ -41,9 +41,9 @@ void RpcServer::OnAsyncAccept(RpcSessionPtr session, const boost::system::error_
 		return;
 	}
 	session->Start();
-	sessions_.insert(session);
+	sessions.insert(session);
 	RpcSessionPtr new_session(new RpcSession(*this));
-	acceptor_.async_accept(new_session->Socket(),
+	acceptor.async_accept(new_session->Socket(),
 			boost::bind(&RpcServer::OnAsyncAccept, this,
 					boost::asio::placeholders::error));
 }
@@ -57,19 +57,19 @@ void RpcServer::OnCallMethod(RpcSessionPtr session, ResponseHandlerPtr response_
 
 void RpcServer::Stop()
 {
-	thread_pool_.Wait();
-	acceptor_.close();
-	foreach(RpcSessionPtr session, sessions_)
+	thread_pool.Wait();
+	acceptor.close();
+	foreach(RpcSessionPtr session, sessions)
 	{
 		session->Stop();
 	}
-	sessions_.clear();
+	sessions.clear();
 }
 
 void RpcServer::RunService(RpcSessionPtr session, RpcMetaPtr meta,
 		StringPtr message, MessageHandler message_handler)
 {
-	MethodInfoPtr method_info = methods_[meta->method];
+	MethodInfoPtr method_info = methods[meta->method];
 
 	ResponseHandlerPtr response_handler(
 			new ResponseHandler(method_info, meta->id, message_handler));
@@ -79,7 +79,7 @@ void RpcServer::RunService(RpcSessionPtr session, RpcMetaPtr meta,
 			shared_from_this(), &RpcServer::OnCallMethod,
 			session, response_handler);
 
-	thread_pool_.Schedule(
+	thread_pool.Schedule(
 			boost::bind(&google::protobuf::Service::CallMethod, this,
 					response_handler->Method(), NULL,
 					response_handler->Request(), response_handler->Response(),
@@ -96,14 +96,14 @@ void RpcServer::RegisterService(RpcServicePtr service)
 				service_descriptor->method(i);
 		std::size_t method_hash = string_hash(method_descriptor->full_name());
 		MethodInfoPtr method_info(new MethodInfo(service, method_descriptor));
-		CHECK(methods_.find(method_hash) == methods_.end());
-		methods_[method_hash] = method_info;
+		CHECK(methods.find(method_hash) == methods.end());
+		methods[method_hash] = method_info;
 	}
 }
 
 void RpcServer::RemoveSession(RpcSessionPtr& session)
 {
-	sessions_.erase(session);
+	sessions.erase(session);
 }
 
 } // namespace Egametang

+ 6 - 6
Src/Egametang/Rpc/RpcServer.h

@@ -12,14 +12,14 @@ private:
 	typedef boost::unordered_set<RpcSessionPtr> RpcSessionSet;
 	typedef boost::unordered_map<std::size_t, MethodInfoPtr> MethodMap;
 
-	boost::asio::io_service& io_service_;
-	boost::asio::ip::tcp::acceptor acceptor_;
-	ThreadPool thread_pool_;
-	RpcSessionSet sessions_;
-	MethodMap methods_;
+	boost::asio::io_service& io_service;
+	boost::asio::ip::tcp::acceptor acceptor;
+	ThreadPool thread_pool;
+	RpcSessionSet sessions;
+	MethodMap methods;
 
 	void OnAsyncAccept(RpcSessionPtr session, const boost::system::error_code& err);
-	void OnCallMethod(RpcSessionPtr session, ResponseHandlerPtr call_method_back);
+	void OnCallMethod(RpcSessionPtr session, ResponseHandlerPtr response_handler);
 
 public:
 	RpcServer(boost::asio::io_service& io_service, int port);

+ 4 - 4
Src/Egametang/Rpc/RpcSession.cc

@@ -3,14 +3,14 @@
 
 namespace Egametang {
 
-RpcSession::RpcSession(RpcServer& rpc_server):
-		rpc_server_(rpc_server), RpcCommunicator(rpc_server_.IOService())
+RpcSession::RpcSession(RpcServer& server):
+		rpc_server(server), RpcCommunicator(rpc_server.IOService())
 {
 }
 
 void RpcSession::OnRecvMessage(RpcMetaPtr meta, StringPtr message)
 {
-	rpc_server_.RunService(shared_from_this(), meta, message,
+	rpc_server.RunService(shared_from_this(), meta, message,
 			boost::bind(&RpcSession::SendMeta, shared_from_this(), _1, _2));
 
 	// 可以循环利用
@@ -31,7 +31,7 @@ void RpcSession::Start()
 void RpcSession::Stop()
 {
 	RpcCommunicator::Stop();
-	rpc_server_.RemoveSession(shared_from_this());
+	rpc_server.RemoveSession(shared_from_this());
 }
 
 } // namespace Egametang

+ 1 - 1
Src/Egametang/Rpc/RpcSession.h

@@ -16,7 +16,7 @@ class RpcSession:
 		public boost::enable_shared_from_this<RpcSession>
 {
 private:
-	RpcServer& rpc_server_;
+	RpcServer& rpc_server;
 
 	virtual void OnRecvMessage(RpcMetaPtr meta, StringPtr message);
 	virtual void OnSendMessage(RpcMetaPtr meta, StringPtr message);

+ 11 - 11
Src/Egametang/Thread/CountBarrier.cc

@@ -3,38 +3,38 @@
 namespace Egametang {
 
 CountBarrier::CountBarrier(int count):
-	count_(count), mutex_(), condition_()
+	count(count), mutex(), condition()
 {
 }
 
 void CountBarrier::Wait()
 {
-	boost::mutex::scoped_lock lock(mutex_);
-	while (count_ > 0)
+	boost::mutex::scoped_lock lock(mutex);
+	while (count > 0)
 	{
-		condition_.wait(lock);
+		condition.wait(lock);
 	}
 }
 
 void CountBarrier::Signal()
 {
-	boost::mutex::scoped_lock lock(mutex_);
-	--count_;
-	if (count_ == 0)
+	boost::mutex::scoped_lock lock(mutex);
+	--count;
+	if (count == 0)
 	{
-		condition_.notify_all();
+		condition.notify_all();
 	}
 }
 
 int CountBarrier::Count() const
 {
-	boost::mutex::scoped_lock lock(mutex_);
-	return count_;
+	boost::mutex::scoped_lock lock(mutex);
+	return count;
 }
 
 void CountBarrier::Reset(int count)
 {
-	count_ = count;
+	this->count = count;
 }
 
 } // namespace Egametang

+ 3 - 3
Src/Egametang/Thread/CountBarrier.h

@@ -8,9 +8,9 @@ namespace Egametang {
 class CountBarrier
 {
 private:
-	int count_;
-	mutable boost::mutex mutex_;
-	boost::condition_variable condition_;
+	int count;
+	mutable boost::mutex mutex;
+	boost::condition_variable condition;
 
 public:
 	explicit CountBarrier(int count = 1);

+ 5 - 5
Src/Egametang/Thread/CountBarrierTest.cc

@@ -13,9 +13,9 @@ namespace Egametang {
 class CountBarrierTest: public testing::Test
 {
 protected:
-	boost::detail::atomic_count count_;
+	boost::detail::atomic_count count;
 public:
-	CountBarrierTest(): count_(0)
+	CountBarrierTest(): count(0)
 	{
 	}
 	virtual ~CountBarrierTest()
@@ -32,7 +32,7 @@ public:
 		boost::xtime_get(&xt, boost::TIME_UTC);
 		xt.sec += 2;
 		boost::thread::sleep(xt);
-		++count_;
+		++count;
 		barrier.Signal();
 	}
 };
@@ -53,9 +53,9 @@ TEST_F(CountBarrierTest, WaitAndSignal)
 				boost::bind(&CountBarrierTest::Signal,
 						this, boost::ref(barrier)));
 	}
-	ASSERT_EQ(0, this->count_);
+	ASSERT_EQ(0, this->count);
 	barrier.Wait();
-	ASSERT_EQ(10, this->count_);
+	ASSERT_EQ(10, this->count);
 	pool.Wait();
 }
 

+ 24 - 24
Src/Egametang/Thread/ThreadPool.cc

@@ -4,19 +4,19 @@
 namespace Egametang {
 
 ThreadPool::ThreadPool(int num) :
-	thread_num_(num), running_(true), work_num_(0)
+	thread_num(num), running(true), work_num(0)
 {
 	if (num == 0)
 	{
-		thread_num_ = boost::thread::hardware_concurrency();
+		thread_num = boost::thread::hardware_concurrency();
 	}
-	for (int i = 0; i < thread_num_; ++i)
+	for (int i = 0; i < thread_num; ++i)
 	{
 		ThreadPtr t(new boost::thread(
 				boost::bind(&ThreadPool::Runner, this)));
-		threads_.push_back(t);
+		threads.push_back(t);
 		t->detach();
-		++work_num_;
+		++work_num;
 	}
 }
 
@@ -26,14 +26,14 @@ ThreadPool::~ThreadPool()
 
 void ThreadPool::Wait()
 {
-	boost::mutex::scoped_lock lock(mutex_);
-	running_ = false;
-	cond_.notify_all();
-	while (work_num_ > 0)
+	boost::mutex::scoped_lock lock(mutex);
+	running = false;
+	cond.notify_all();
+	while (work_num > 0)
 	{
-		done_.wait(lock);
+		done.wait(lock);
 	}
-	running_ = true;
+	running = true;
 }
 
 void ThreadPool::Runner()
@@ -43,17 +43,17 @@ void ThreadPool::Runner()
 	{
 		boost::function<void (void)> task;
 		{
-			boost::mutex::scoped_lock lock(mutex_);
-			while (running_ && tasks_.empty())
+			boost::mutex::scoped_lock lock(mutex);
+			while (running && tasks.empty())
 			{
-				cond_.wait(lock);
+				cond.wait(lock);
 			}
-			if (!tasks_.empty())
+			if (!tasks.empty())
 			{
-				task = tasks_.front();
-				tasks_.pop_front();
+				task = tasks.front();
+				tasks.pop_front();
 			}
-			continued = running_ || !tasks_.empty();
+			continued = running || !tasks.empty();
 		}
 
 		if (task)
@@ -61,23 +61,23 @@ void ThreadPool::Runner()
 			task();
 		}
 	}
-	if (--work_num_ == 0)
+	if (--work_num == 0)
 	{
-		done_.notify_one();
+		done.notify_one();
 	}
 }
 
 bool ThreadPool::Schedule(boost::function<void (void)> task)
 {
 	{
-		boost::mutex::scoped_lock lock(mutex_);
-		if (!running_)
+		boost::mutex::scoped_lock lock(mutex);
+		if (!running)
 		{
 			return false;
 		}
-		tasks_.push_back(task);
+		tasks.push_back(task);
 	}
-	cond_.notify_one();
+	cond.notify_one();
 	return true;
 }
 

+ 8 - 8
Src/Egametang/Thread/ThreadPool.h

@@ -13,14 +13,14 @@ namespace Egametang {
 class ThreadPool: private boost::noncopyable
 {
 private:
-	int thread_num_;
-	boost::detail::atomic_count work_num_;
-	volatile bool running_;
-	boost::mutex mutex_;
-	boost::condition_variable cond_;
-	boost::condition_variable done_;
-	std::list<ThreadPtr> threads_;
-	std::list<boost::function<void (void)> > tasks_;
+	int thread_num;
+	boost::detail::atomic_count work_num;
+	volatile bool running;
+	boost::mutex mutex;
+	boost::condition_variable cond;
+	boost::condition_variable done;
+	std::list<ThreadPtr> threads;
+	std::list<boost::function<void (void)> > tasks;
 
 	void Runner();
 public:

+ 4 - 4
Src/Egametang/Thread/ThreadPoolTest.cc

@@ -10,10 +10,10 @@ namespace Egametang {
 class ThreadPoolTest: public testing::Test
 {
 protected:
-	ThreadPool pool_;
+	ThreadPool pool;
 
 public:
-	ThreadPoolTest() : pool_(10)
+	ThreadPoolTest() : pool(10)
 	{
 	}
 
@@ -34,11 +34,11 @@ TEST_F(ThreadPoolTest, Test1)
 	std::vector<int> z(100, 0);
 	for (int i = 0; i < 100; ++i)
 	{
-		pool_.Schedule(
+		pool.Schedule(
 				boost::bind(&ThreadPoolTest::Max,
 						this, x[i], y[i], &z[i]));
 	}
-	pool_.Wait();
+	pool.Wait();
 	for (int i = 0; i < 100; ++i)
 	{
 		ASSERT_EQ(9, z[i]) << "i = " << i;