Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
youngwolf
ascs
提交
e5a480cc
A
ascs
项目概览
youngwolf
/
ascs
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ascs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e5a480cc
编写于
5月 30, 2019
作者:
Y
yang li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix performance downgrade introduced in version 1.4.2
上级
c0c1366d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
21 addition
and
13 deletion
+21
-13
examples/echo_server/echo_server.cpp
examples/echo_server/echo_server.cpp
+1
-1
include/ascs/base.h
include/ascs/base.h
+8
-0
include/ascs/socket.h
include/ascs/socket.h
+3
-2
include/ascs/tcp/socket.h
include/ascs/tcp/socket.h
+9
-10
未找到文件。
examples/echo_server/echo_server.cpp
浏览文件 @
e5a480cc
...
...
@@ -8,7 +8,7 @@
//#define ASCS_SYNC_DISPATCH //do not open this feature, see below for more details
#define ASCS_DISPATCH_BATCH_MSG
#define ASCS_ENHANCED_STABILITY
#define ASCS_FULL_STATISTIC //full statistic will slightly impact efficiency
//
#define ASCS_FULL_STATISTIC //full statistic will slightly impact efficiency
#define ASCS_USE_STEADY_TIMER
#define ASCS_ALIGNED_TIMER
#define ASCS_AVOID_AUTO_STOP_SERVICE
...
...
include/ascs/base.h
浏览文件 @
e5a480cc
...
...
@@ -488,6 +488,14 @@ size_t get_size_in_byte(const _Can& __can)
return
size_in_byte
;
}
template
<
typename
_Can
>
size_t
get_size_in_byte
(
const
_Can
&
__can
,
size_t
&
size
)
{
auto
size_in_byte
=
size
=
0
;
do_something_to_all
(
__can
,
[
&
size_in_byte
,
&
size
](
typename
_Can
::
const_reference
item
)
{
size_in_byte
+=
item
.
size
();
++
size
;});
return
size_in_byte
;
}
//member functions, used to do something to any member container(except map and multimap) optionally with any member mutex
#define DO_SOMETHING_TO_ALL_MUTEX(CAN, MUTEX) DO_SOMETHING_TO_ALL_MUTEX_NAME(do_something_to_all, CAN, MUTEX)
#define DO_SOMETHING_TO_ALL(CAN) DO_SOMETHING_TO_ALL_NAME(do_something_to_all, CAN)
...
...
include/ascs/socket.h
浏览文件 @
e5a480cc
...
...
@@ -370,8 +370,9 @@ protected:
bool
handle_msg
()
{
auto
size_in_byte
=
ascs
::
get_size_in_byte
(
temp_msg_can
);
stat
.
recv_msg_sum
+=
temp_msg_can
.
size
();
//this can have linear complexity in old gcc or Cygwin and Mingw64, please note.
size_t
size
=
0
;
auto
size_in_byte
=
ascs
::
get_size_in_byte
(
temp_msg_can
,
size
);
stat
.
recv_msg_sum
+=
size
;
stat
.
recv_byte_sum
+=
size_in_byte
;
#ifdef ASCS_SYNC_RECV
std
::
unique_lock
<
std
::
mutex
>
lock
(
sync_recv_mutex
);
...
...
include/ascs/tcp/socket.h
浏览文件 @
e5a480cc
...
...
@@ -300,18 +300,16 @@ private:
#else
send_msg_buffer
.
move_items_out
(
asio
::
detail
::
default_max_transfer_size
,
last_send_msg
);
#endif
std
::
vector
<
asio
::
const_buffer
>
bufs
;
bufs
.
reserve
(
last_send_msg
.
size
());
for
(
auto
iter
=
std
::
begin
(
last_send_msg
);
iter
!=
std
::
end
(
last_send_msg
);
++
iter
)
{
stat
.
send_delay_sum
+=
end_time
-
iter
->
begin_time
;
bufs
.
emplace_back
(
iter
->
data
(),
iter
->
size
());
}
send_bufs
.
clear
();
//this buffer will not be refreshed according to last_send_msg timely
ascs
::
do_something_to_all
(
last_send_msg
,
[
this
,
&
end_time
](
typename
super
::
in_msg
&
item
)
{
this
->
stat
.
send_delay_sum
+=
end_time
-
item
.
begin_time
;
this
->
send_bufs
.
emplace_back
(
item
.
data
(),
item
.
size
());
});
if
((
sending
=
!
bufs
.
empty
()))
if
((
sending
=
!
send_
bufs
.
empty
()))
{
last_send_msg
.
front
().
restart
();
asio
::
async_write
(
this
->
next_layer
(),
bufs
,
make_strand_handler
(
strand
,
asio
::
async_write
(
this
->
next_layer
(),
send_
bufs
,
make_strand_handler
(
strand
,
this
->
make_handler_error_size
([
this
](
const
asio
::
error_code
&
ec
,
size_t
bytes_transferred
)
{
this
->
send_handler
(
ec
,
bytes_transferred
);})));
return
true
;
}
...
...
@@ -327,7 +325,7 @@ private:
stat
.
send_byte_sum
+=
bytes_transferred
;
stat
.
send_time_sum
+=
statistic
::
now
()
-
last_send_msg
.
front
().
begin_time
;
stat
.
send_msg_sum
+=
last_send_msg
.
size
();
stat
.
send_msg_sum
+=
send_bufs
.
size
();
#ifdef ASCS_SYNC_SEND
ascs
::
do_something_to_all
(
last_send_msg
,
[](
typename
super
::
in_msg
&
item
)
{
if
(
item
.
p
)
{
item
.
p
->
set_value
(
sync_call_result
::
SUCCESS
);}});
#endif
...
...
@@ -391,6 +389,7 @@ private:
std
::
shared_ptr
<
i_unpacker
<
out_msg_type
>>
unpacker_
;
typename
super
::
in_container_type
last_send_msg
;
std
::
vector
<
asio
::
const_buffer
>
send_bufs
;
//just to reduce memory allocation and keep the size of sending items (linear complexity, it's very important)
asio
::
io_context
::
strand
strand
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录