Преглед изворни кода

修正了一些格式问题,接下来实现protobuf rpc

tanghai пре 15 година
родитељ
комит
335fccbdc1
4 измењених фајлова са 12 додато и 13 уклоњено
  1. 4 4
      SConstruct
  2. 1 1
      src/net/connection.h
  3. 7 7
      src/thread/thread_pool.cc
  4. 0 1
      src/thread/thread_pool.h

+ 4 - 4
SConstruct

@@ -8,10 +8,10 @@ def ParseOptions():
 		default='dbg',
 		help='build in opt mode, default dbg mode')
 	AddOption("--ntest",
-    action="store_true",
-    dest="ntest",
-    default=False,
-    help="dont build test")
+	    action="store_true",
+	    dest="ntest",
+	    default=False,
+	    help="dont build test")
 
 ParseOptions()
 

+ 1 - 1
src/net/connection.h

@@ -30,7 +30,7 @@ public:
 	void stop();
 	virtual void handle_read(const boost::system::error_code& e,
 			size_t bytes_transferred) = 0;
-	virtual void handle_writer(const boost::system::error_code& e) = 0;
+	virtual void handle_write(const boost::system::error_code& e) = 0;
 };
 
 } // namespace hainan

+ 7 - 7
src/thread/thread_pool.cc

@@ -30,7 +30,7 @@ void thread_pool::stop()
 	boost::mutex::scoped_lock lock(mutex_);
 	running_ = false;
 	cond_.notify_all();
-	while(work_num_ > 0)
+	while (work_num_ > 0)
 	{
 		VLOG(3) << "done tasks size = " << tasks_.size();
 		done_.wait(lock);
@@ -41,19 +41,19 @@ void thread_pool::runner()
 {
 	VLOG(3) << "thread start";
 	bool continued = true;
-	while(continued)
+	while (continued)
 	{
 		boost::function<void (void)> task;
 		{
 			VLOG(3) << "loop lock";
 			boost::mutex::scoped_lock lock(mutex_);
 			VLOG(3) << "loop lock ok";
-			while(running_ && tasks_.empty())
+			while (running_ && tasks_.empty())
 			{
 				cond_.wait(lock);
 				VLOG(3) << "cond";
 			}
-			if(!tasks_.empty())
+			if (!tasks_.empty())
 			{
 				VLOG(3) << "fetch task";
 				task = tasks_.front();
@@ -66,12 +66,12 @@ void thread_pool::runner()
 			VLOG(3) << "loop unlock";
 		}
 
-		if(task)
+		if (task)
 		{
 			task();
 		}
 	}
-	if(__sync_sub_and_fetch(&work_num_, 1) == 0)
+	if (__sync_sub_and_fetch(&work_num_, 1) == 0)
 	{
 		VLOG(3) << "work_num = " << work_num_;
 		done_.notify_one();
@@ -83,7 +83,7 @@ bool thread_pool::push_task(boost::function<void (void)> task)
 	VLOG(3) << "push task";
 	{
 		boost::mutex::scoped_lock lock(mutex_);
-		if(!running_)
+		if (!running_)
 		{
 			return false;
 		}

+ 0 - 1
src/thread/thread_pool.h

@@ -1,7 +1,6 @@
 #ifndef THREAD_THREAD_POOL_H
 #define THREAD_THREAD_POOL_H
 
-#include <vector>
 #include <list>
 #include <boost/thread.hpp>
 #include <boost/function.hpp>