Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
youngwolf
ascs
提交
99032b7f
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,体验更适合开发者的 AI 搜索 >>
提交
99032b7f
编写于
9月 02, 2021
作者:
Y
youngwolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
demonstrate strict reference balance between multiple io_context.
上级
5dfdef73
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
4 deletion
+17
-4
examples/echo_client/echo_client.cpp
examples/echo_client/echo_client.cpp
+10
-0
examples/echo_server/echo_server.cpp
examples/echo_server/echo_server.cpp
+3
-0
include/ascs/config.h
include/ascs/config.h
+3
-3
include/ascs/socket.h
include/ascs/socket.h
+1
-1
未找到文件。
examples/echo_client/echo_client.cpp
浏览文件 @
99032b7f
...
...
@@ -165,6 +165,16 @@ protected:
}
#endif
//demonstrate strict reference balance between multiple io_context.
virtual
bool
change_io_context
()
{
if
(
nullptr
==
get_matrix
())
return
false
;
reset_next_layer
(
get_matrix
()
->
get_service_pump
().
assign_io_context
());
return
true
;
}
private:
void
handle_msg
(
out_msg_ctype
&
msg
)
{
...
...
examples/echo_server/echo_server.cpp
浏览文件 @
99032b7f
...
...
@@ -151,6 +151,9 @@ protected:
virtual
bool
on_msg_handle
(
out_msg_type
&
msg
)
{
return
send_msg
(
std
::
move
(
msg
));}
#endif
//msg handling end
//demonstrate strict reference balance between multiple io_context.
virtual
bool
change_io_context
()
{
reset_next_layer
(
get_server
().
get_service_pump
().
assign_io_context
());
return
true
;}
};
class
echo_server
:
public
server_base
<
echo_socket
,
object_pool
<
echo_socket
>
,
i_echo_server
>
...
...
include/ascs/config.h
浏览文件 @
99032b7f
...
...
@@ -760,9 +760,9 @@
*
* HIGHLIGHT:
* service_pump support multiple io_context, just needs the number of service thread to be bigger than or equal to the number of io_context.
* Introduce virtual function change_io_context() to ascs::socket to balance the reference of io_context strictly,
* this is because after a socket been reused, its next_layer still based on previous io_context, this may break the
balance of io_context,
* re-write this virtual function to re-create the next_layer base on the io_context which has the least references.
* Introduce virtual function change_io_context() to ascs::socket to balance the reference of
multiple
io_context strictly,
* this is because after a socket been reused, its next_layer still based on previous io_context, this may break the
reference balance of
*
multiple io_context,
re-write this virtual function to re-create the next_layer base on the io_context which has the least references.
* ssl's server_socket_base and client_socket_base already did this, please note.
* Support reliable UDP (based on KCP -- https://github.com/skywind3000/kcp.git).
* Support connected UDP socket, set macro ASCS_UDP_CONNECT_MODE to true to open it, you must also provide peer's ip address via set_peer_addr,
...
...
include/ascs/socket.h
浏览文件 @
99032b7f
...
...
@@ -339,7 +339,7 @@ protected:
virtual
void
on_close
()
{
unified_out
::
info_out
(
ASCS_LLF
" on_close()"
,
id
());}
virtual
void
after_close
()
{}
//a good case for using this is to reconnect the server, please refer to client_socket_base.
//reused socket still based on previous io_context, and may break the
balance of io_context, if you want to balance io_contex
t strictly,
//reused socket still based on previous io_context, and may break the
reference balance of multiple io_context, if you want to balance i
t strictly,
// re-write this virtual function to re-create the next_layer base on the io_context which has the least references and return true, like:
//virtual bool change_io_context() {this->reset_next_layer(this->get_server().get_service_pump().assign_io_context()); return true;} or
//virtual bool change_io_context()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录