fixed tab

This commit is contained in:
wangyu- 2017-10-08 01:51:26 -05:00
parent fb3edca8e4
commit d5483d4984

View File

@ -24,26 +24,26 @@ void server_clear_function(u64_t u64)//used in conv_manager in server mode.for s
} }
conv_manager_t::conv_manager_t() conv_manager_t::conv_manager_t()
{ {
clear_it=conv_last_active_time.begin(); clear_it=conv_last_active_time.begin();
long long last_clear_time=0; long long last_clear_time=0;
} }
conv_manager_t::~conv_manager_t() conv_manager_t::~conv_manager_t()
{ {
clear(); clear();
} }
int conv_manager_t::get_size() int conv_manager_t::get_size()
{ {
return conv_to_u64.size(); return conv_to_u64.size();
} }
void conv_manager_t::reserve() void conv_manager_t::reserve()
{ {
u64_to_conv.reserve(10007); u64_to_conv.reserve(10007);
conv_to_u64.reserve(10007); conv_to_u64.reserve(10007);
conv_last_active_time.reserve(10007); conv_last_active_time.reserve(10007);
} }
void conv_manager_t::clear() void conv_manager_t::clear()
{ {
if(disable_conv_clear) return ; if(disable_conv_clear) return ;
if(program_mode==server_mode) if(program_mode==server_mode)
@ -60,38 +60,38 @@ conv_manager_t::~conv_manager_t()
clear_it=conv_last_active_time.begin(); clear_it=conv_last_active_time.begin();
} }
u32_t conv_manager_t::get_new_conv() u32_t conv_manager_t::get_new_conv()
{ {
u32_t conv=get_true_random_number_nz(); u32_t conv=get_true_random_number_nz();
while(conv_to_u64.find(conv)!=conv_to_u64.end()) while(conv_to_u64.find(conv)!=conv_to_u64.end())
{ {
conv=get_true_random_number_nz(); conv=get_true_random_number_nz();
} }
return conv; return conv;
} }
int conv_manager_t::is_conv_used(u32_t conv) int conv_manager_t::is_conv_used(u32_t conv)
{ {
return conv_to_u64.find(conv)!=conv_to_u64.end(); return conv_to_u64.find(conv)!=conv_to_u64.end();
} }
int conv_manager_t::is_u64_used(u64_t u64) int conv_manager_t::is_u64_used(u64_t u64)
{ {
return u64_to_conv.find(u64)!=u64_to_conv.end(); return u64_to_conv.find(u64)!=u64_to_conv.end();
} }
u32_t conv_manager_t::find_conv_by_u64(u64_t u64) u32_t conv_manager_t::find_conv_by_u64(u64_t u64)
{ {
return u64_to_conv[u64]; return u64_to_conv[u64];
} }
u64_t conv_manager_t::find_u64_by_conv(u32_t conv) u64_t conv_manager_t::find_u64_by_conv(u32_t conv)
{ {
return conv_to_u64[conv]; return conv_to_u64[conv];
} }
int conv_manager_t::update_active_time(u32_t conv) int conv_manager_t::update_active_time(u32_t conv)
{ {
return conv_last_active_time[conv]=get_current_time(); return conv_last_active_time[conv]=get_current_time();
} }
int conv_manager_t::insert_conv(u32_t conv,u64_t u64)//////todo add capacity int conv_manager_t::insert_conv(u32_t conv,u64_t u64)//////todo add capacity
{ {
int bucket_size_before=conv_last_active_time.bucket_count(); int bucket_size_before=conv_last_active_time.bucket_count();
u64_to_conv[u64]=conv; u64_to_conv[u64]=conv;
conv_to_u64[conv]=u64; conv_to_u64[conv]=u64;
@ -100,9 +100,9 @@ conv_manager_t::~conv_manager_t()
if(bucket_size_after!=bucket_size_before) if(bucket_size_after!=bucket_size_before)
clear_it=conv_last_active_time.begin(); clear_it=conv_last_active_time.begin();
return 0; return 0;
} }
int conv_manager_t::erase_conv(u32_t conv) int conv_manager_t::erase_conv(u32_t conv)
{ {
//if(disable_conv_clear) return 0; //if(disable_conv_clear) return 0;
assert(conv_last_active_time.find(conv)!=conv_last_active_time.end()); assert(conv_last_active_time.find(conv)!=conv_last_active_time.end());
u64_t u64=conv_to_u64[conv]; u64_t u64=conv_to_u64[conv];
@ -115,18 +115,18 @@ conv_manager_t::~conv_manager_t()
u64_to_conv.erase(u64); u64_to_conv.erase(u64);
conv_last_active_time.erase(conv); conv_last_active_time.erase(conv);
return 0; return 0;
} }
int conv_manager_t::clear_inactive(char * ip_port) int conv_manager_t::clear_inactive(char * ip_port)
{ {
if(get_current_time()-last_clear_time>conv_clear_interval) if(get_current_time()-last_clear_time>conv_clear_interval)
{ {
last_clear_time=get_current_time(); last_clear_time=get_current_time();
return clear_inactive0(ip_port); return clear_inactive0(ip_port);
} }
return 0; return 0;
} }
int conv_manager_t::clear_inactive0(char * ip_port) int conv_manager_t::clear_inactive0(char * ip_port)
{ {
if(disable_conv_clear) return 0; if(disable_conv_clear) return 0;
//map<uint32_t,uint64_t>::iterator it; //map<uint32_t,uint64_t>::iterator it;
@ -171,7 +171,10 @@ conv_manager_t::~conv_manager_t()
cnt++; cnt++;
} }
return 0; return 0;
} }
conn_manager_t::conn_manager_t() conn_manager_t::conn_manager_t()
{ {
//ready_num=0; //ready_num=0;