|
@@ -14,10 +14,23 @@ void ProcReq(std::shared_ptr<char> pstr_req,const int nreqsize,std::shared_ptr<c
|
|
nressize = 100;
|
|
nressize = 100;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void ProcAsync(std::shared_ptr<char> & pstr_res,int & ndatasize,int nres)
|
|
|
|
+{
|
|
|
|
+ if(nres == 0)
|
|
|
|
+ {
|
|
|
|
+ std::cout<<"extend time."<<std::endl;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(nres == 1)
|
|
|
|
+ {
|
|
|
|
+ std::cout<<"Aysnc Service return."<<std::endl;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
void threadclientai(int ai)
|
|
void threadclientai(int ai)
|
|
{
|
|
{
|
|
- iv::service::Client xclient("hellob");
|
|
|
|
|
|
+ iv::service::Client xclient("helloa");
|
|
|
|
|
|
// std::this_thread::sleep_for(std::chrono::milliseconds(3));
|
|
// std::this_thread::sleep_for(std::chrono::milliseconds(3));
|
|
// std::cout<<"Send Time : "<<QDateTime::currentMSecsSinceEpoch()<<std::endl;
|
|
// std::cout<<"Send Time : "<<QDateTime::currentMSecsSinceEpoch()<<std::endl;
|
|
@@ -41,6 +54,7 @@ void threadclientai(int ai)
|
|
{
|
|
{
|
|
std::cout<<ai<<" Fail Get Result."<<std::endl;
|
|
std::cout<<ai<<" Fail Get Result."<<std::endl;
|
|
}
|
|
}
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
void threadclient()
|
|
void threadclient()
|
|
@@ -83,6 +97,9 @@ void threadclient()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
int main(int argc, char *argv[])
|
|
int main(int argc, char *argv[])
|
|
{
|
|
{
|
|
QCoreApplication a(argc, argv);
|
|
QCoreApplication a(argc, argv);
|
|
@@ -94,11 +111,22 @@ int main(int argc, char *argv[])
|
|
qint64 xtime1 = std::chrono::system_clock::now().time_since_epoch().count();
|
|
qint64 xtime1 = std::chrono::system_clock::now().time_since_epoch().count();
|
|
qint64 xtime2 = std::chrono::system_clock::now().time_since_epoch().count();
|
|
qint64 xtime2 = std::chrono::system_clock::now().time_since_epoch().count();
|
|
qint64 xtd = xtime2 - xtime1;
|
|
qint64 xtd = xtime2 - xtime1;
|
|
- iv::service::Server xserver("hellob",ProcReq);
|
|
|
|
- std::this_thread::sleep_for(std::chrono::milliseconds(300));
|
|
|
|
- std::thread * pthread_a = new std::thread(threadclientai,1);
|
|
|
|
|
|
+// iv::service::Server xserver("helloa",ProcReq);
|
|
// std::this_thread::sleep_for(std::chrono::milliseconds(300));
|
|
// std::this_thread::sleep_for(std::chrono::milliseconds(300));
|
|
- std::thread * pthread_b = new std::thread(threadclientai,2);
|
|
|
|
|
|
+// std::thread * pthread_a = new std::thread(threadclientai,1);
|
|
|
|
+// std::thread * pthread_b = new std::thread(threadclientai,2);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ iv::service::Client xaync("async");
|
|
|
|
+ std::shared_ptr<char> pstr_async = std::shared_ptr<char>(new char[1000]);
|
|
|
|
+ xaync.AsyncSendRequest(pstr_async,100,ProcAsync);
|
|
|
|
+
|
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(10000));
|
|
|
|
+ iv::service::Server xserver("async",ProcReq);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
// std::thread * pthread = new std::thread(threadclient);
|
|
// std::thread * pthread = new std::thread(threadclient);
|
|
// int i;
|
|
// int i;
|
|
// for(i=0;i<100;i++)
|
|
// for(i=0;i<100;i++)
|