区分用户和系统
This commit is contained in:
parent
21332b63ad
commit
c71e7fb8b5
@ -177,8 +177,14 @@ namespace f8
|
||||
long long begin_tick = a8::XGetTickCount();
|
||||
ret = a8::http::Get(finally_url, response, &node->headers, 10);
|
||||
long long end_tick = a8::XGetTickCount();
|
||||
if (end_tick - begin_tick > f8::HttpClientPool::Instance()->max_request_delay) {
|
||||
f8::HttpClientPool::Instance()->max_request_delay = end_tick - begin_tick;
|
||||
if (thread_id <= f8::HttpClientPool::Instance()->sys_num) {
|
||||
if (end_tick - begin_tick > f8::HttpClientPool::Instance()->max_sys_request_delay) {
|
||||
f8::HttpClientPool::Instance()->max_sys_request_delay = end_tick - begin_tick;
|
||||
}
|
||||
} else {
|
||||
if (end_tick - begin_tick > f8::HttpClientPool::Instance()->max_user_request_delay) {
|
||||
f8::HttpClientPool::Instance()->max_user_request_delay = end_tick - begin_tick;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -187,8 +193,14 @@ namespace f8
|
||||
long long begin_tick = a8::XGetTickCount();
|
||||
ret = a8::http::Post(finally_url.c_str(), node->content, response, &node->headers, 10);
|
||||
long long end_tick = a8::XGetTickCount();
|
||||
if (end_tick - begin_tick > f8::HttpClientPool::Instance()->max_request_delay) {
|
||||
f8::HttpClientPool::Instance()->max_request_delay = end_tick - begin_tick;
|
||||
if (thread_id <= f8::HttpClientPool::Instance()->sys_num) {
|
||||
if (end_tick - begin_tick > f8::HttpClientPool::Instance()->max_sys_request_delay) {
|
||||
f8::HttpClientPool::Instance()->max_sys_request_delay = end_tick - begin_tick;
|
||||
}
|
||||
} else {
|
||||
if (end_tick - begin_tick > f8::HttpClientPool::Instance()->max_user_request_delay) {
|
||||
f8::HttpClientPool::Instance()->max_user_request_delay = end_tick - begin_tick;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -226,6 +238,7 @@ namespace f8
|
||||
|
||||
public:
|
||||
int exec_async_http_msgid = 0;
|
||||
int thread_id = 0;
|
||||
|
||||
private:
|
||||
volatile bool terminated = false;
|
||||
@ -304,6 +317,7 @@ namespace f8
|
||||
for (int i = 0; i < thread_num; i++) {
|
||||
HttpThread *http_thread = new HttpThread();
|
||||
http_thread->exec_async_http_msgid = exec_async_http_msgid;
|
||||
http_thread->thread_id = i;
|
||||
http_thread->Init();
|
||||
http_thread_pool.push_back(http_thread);
|
||||
}
|
||||
@ -414,8 +428,17 @@ namespace f8
|
||||
#endif
|
||||
};
|
||||
|
||||
void HttpClientPool::Init(int thread_num)
|
||||
void HttpClientPool::Init(int thread_num, int sys_num, int user_num)
|
||||
{
|
||||
if (thread_num < 0 || sys_num < 0 || user_num < 0) {
|
||||
abort();
|
||||
}
|
||||
if (thread_num != sys_num + user_num) {
|
||||
abort();
|
||||
}
|
||||
this->thread_num = thread_num;
|
||||
this->sys_num = sys_num;
|
||||
this->user_num = user_num;
|
||||
impl_ = new HttpClientPoolImpl();
|
||||
impl_->Init();
|
||||
MsgQueue::Instance()->RegisterCallBack(impl_->exec_async_http_msgid,
|
||||
|
@ -14,10 +14,14 @@ namespace f8
|
||||
friend class a8::Singleton<HttpClientPool>;
|
||||
|
||||
public:
|
||||
volatile long long max_request_delay = 0;
|
||||
volatile long long max_sys_request_delay = 0;
|
||||
volatile long long max_user_request_delay = 0;
|
||||
volatile int thread_num = 0;
|
||||
volatile int sys_num = 0;
|
||||
volatile int user_num = 0;
|
||||
|
||||
public:
|
||||
void Init(int thread_num);
|
||||
void Init(int thread_num, int sys_num, int user_num);
|
||||
void UnInit();
|
||||
|
||||
//执行异步http get
|
||||
|
Loading…
x
Reference in New Issue
Block a user