Przeglądaj źródła

ThreadPool PushTask函数改名为Schedule

tanghai 14 lat temu
rodzic
commit
e885177670

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

@@ -107,8 +107,8 @@ TEST_F(RpcChannelTest, Echo)
 	EchoService_Stub service(&rpc_channel);
 
 	ThreadPool thread_pool(2);
-	thread_pool.PushTask(boost::bind(&IOServiceRun, boost::ref(io_server)));
-	thread_pool.PushTask(boost::bind(&IOServiceRun, boost::ref(io_client)));
+	thread_pool.Schedule(boost::bind(&IOServiceRun, boost::ref(io_server)));
+	thread_pool.Schedule(boost::bind(&IOServiceRun, boost::ref(io_client)));
 
 	EchoRequest request;
 	request.set_num(100);

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

@@ -172,8 +172,8 @@ public:
 TEST_F(RpcCommunicatorTest, SendAndRecvString)
 {
 	ThreadPool thread_pool(2);
-	thread_pool.PushTask(boost::bind(&RpcServerTest::Start, &rpc_server_));
-	thread_pool.PushTask(boost::bind(&RpcClientTest::Start, &rpc_client_));
+	thread_pool.Schedule(boost::bind(&RpcServerTest::Start, &rpc_server_));
+	thread_pool.Schedule(boost::bind(&RpcClientTest::Start, &rpc_client_));
 	barrier_.Wait();
 	thread_pool.Wait();
 	rpc_server_.Stop();

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

@@ -61,7 +61,7 @@ void RpcServer::RunService(RpcSessionPtr session, RpcRequestPtr request,
 {
 	google::protobuf::Closure* done = google::protobuf::NewCallback(
 			this, &RpcServer::Callback, session, handler);
-	thread_pool_.PushTask(
+	thread_pool_.Schedule(
 			boost::bind(&google::protobuf::Service::CallMethod, &service_,
 					method, NULL, request.get(), done));
 }

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

@@ -49,7 +49,7 @@ TEST_F(CountBarrierTest, WaitAndSignal)
 	ThreadPool pool(10);
 	for (int i = 0; i < 10; ++i)
 	{
-		pool.PushTask(
+		pool.Schedule(
 				boost::bind(&CountBarrierTest::Signal,
 						this, boost::ref(barrier)));
 	}

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

@@ -67,7 +67,7 @@ void ThreadPool::Runner()
 	}
 }
 
-bool ThreadPool::PushTask(boost::function<void (void)> task)
+bool ThreadPool::Schedule(boost::function<void (void)> task)
 {
 	{
 		boost::mutex::scoped_lock lock(mutex_);

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

@@ -28,7 +28,7 @@ public:
 	virtual ~ThreadPool();
 
 	virtual void Wait();
-	virtual bool PushTask(boost::function<void (void)> task);
+	virtual bool Schedule(boost::function<void (void)> task);
 };
 
 } // namespace Egametang

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

@@ -34,7 +34,7 @@ TEST_F(ThreadPoolTest, Test1)
 	std::vector<int> z(100, 0);
 	for (int i = 0; i < 100; ++i)
 	{
-		pool_.PushTask(
+		pool_.Schedule(
 				boost::bind(&ThreadPoolTest::Max,
 						this, x[i], y[i], &z[i]));
 	}