123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
-
- #include "hello_test.h"
- TEST_F(HelloTest, rpcASyncGlobalCommunicator)
- {
- shared_ptr<Communicator> c = getCommunicator();
- transGlobalCommunicator([&](Communicator *comm){
- checkASync(comm);
- }, c.get());
- }
- TEST_F(HelloTest, rpcASyncGlobalCommunicatorInCoroutine)
- {
- shared_ptr<Communicator> c = getCommunicator();
- transInCoroutineGlobalCommunicator([&](Communicator *comm){
- checkASync(comm);
- }, c.get());
- }
- TEST_F(HelloTest, rpcASyncServerCommunicator)
- {
- transServerCommunicator([&](Communicator *comm){
- checkASync(comm);
- });
- }
- TEST_F(HelloTest, rpcASyncServerCommunicatorInCoroutine)
- {
- transInCoroutineServerCommunicator([&](Communicator *comm){
- checkASync(comm);
- });
- }
- TEST_F(HelloTest, rpcASyncAllocCommunicator)
- {
- transAllocCommunicator([&](Communicator *comm){
- checkASync(comm);
- });
- }
- TEST_F(HelloTest, rpcASyncAllocCommunicatorInCoroutine)
- {
- transInCoroutineAllocCommunicator([&](Communicator *comm){
- checkASync(comm);
- });
- }
- TEST_F(HelloTest, rpcASyncComplexCommunicator)
- {
- shared_ptr<Communicator> c = getCommunicator();
- transComplexCommunicator([&](Communicator *comm){
- checkASync(comm);
- }, c.get());
- transComplexCommunicator([&](Communicator *comm){
- checkASync(comm);
- }, c.get());
- transComplexCommunicator([&](Communicator *comm){
- checkASync(comm);
- }, c.get());
- transComplexCommunicator([&](Communicator *comm){
- checkASync(comm);
- }, c.get());
- }
- TEST_F(HelloTest, rpcASyncComplexCommunicatorInCoroutine)
- {
- shared_ptr<Communicator> c = getCommunicator();
- transInCoroutineComplexCommunicator([&](Communicator *comm)
- {
- checkASync(comm);
- },
- c.get());
- transInCoroutineComplexCommunicator([&](Communicator *comm){
- checkASync(comm);
- }, c.get());
- transInCoroutineComplexCommunicator([&](Communicator *comm){
- checkASync(comm);
- }, c.get());
- transInCoroutineComplexCommunicator([&](Communicator *comm){
- checkASync(comm);
- }, c.get());
- }
- TEST_F(HelloTest, rpcASyncThreadFinish)
- {
- shared_ptr<Communicator> c = getCommunicator();
- HelloServer server;
- startServer(server, (TC_EpollServer::SERVER_OPEN_COROUTINE) 0);
- atomic<int> callback_count{0};
- int count = 10000;
- {
- std::thread cor_call([&]()
- {
- HelloPrx prx = getObj<HelloPrx>(c.get(), "HelloAdapter");
- //发起远程调用
- for (int j = 0; j < count; ++j)
- {
- HelloPrxCallbackPtr p = new ClientHelloCallback(TC_Common::now2us(), j, count, _buffer, callback_count);
- prx->async_testHello(p, j, _buffer);
- }
- });
- cor_call.join();
- }
- waitForFinish(callback_count, count);
- // TC_Common::sleep(10);
- // LOG_CONSOLE_DEBUG << _count << ", " << callback_count << endl;
- ASSERT_TRUE(count == callback_count);
- stopServer(server);
- }
|