@@ -164,6 +164,8 @@ TEST_F(RpcCommunicatorTest, SendAndRecvString)
{
boost::threadpool::fifo_pool threadPool(2);
threadPool.schedule(boost::bind(&RpcServerTest::Start, &rpcServer));
+
+ boost::this_thread::sleep(boost::posix_time::milliseconds(100));
threadPool.schedule(boost::bind(&RpcClientTest::Start, &rpcClient));
barrier.Wait();
threadPool.wait();
@@ -14,7 +14,7 @@ namespace Egametang {
RpcServer::RpcServer(boost::asio::io_service& service, int port):
ioService(service), acceptor(ioService),
- threadPool(), sessions(),
+ threadPool(1), sessions(),
methods()
boost::asio::ip::address address;
@@ -82,6 +82,8 @@ TEST_F(RpcServerTest, ClientAndServer)
// server和client分别在两个不同的线程
threadPool.schedule(boost::bind(&IOServiceRun, &ioServer));
+ // 等待server OK
threadPool.schedule(boost::bind(&IOServiceRun, &ioClient));
CountBarrier barrier;
@@ -28,10 +28,7 @@ public:
}
void Signal(CountBarrier& barrier)
- boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC);
- xt.sec += 1;
- boost::thread::sleep(xt);
+ boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
++count;
barrier.Signal();