Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
youngwolf
ascs
提交
b40c9146
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 搜索 >>
提交
b40c9146
编写于
1月 19, 2023
作者:
Y
youngwolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix compilation error in demo echo_server for very old GCC (at least 4.x).
上级
6ab0b681
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
12 deletion
+19
-12
examples/echo_server/echo_server.cpp
examples/echo_server/echo_server.cpp
+19
-12
未找到文件。
examples/echo_server/echo_server.cpp
浏览文件 @
b40c9146
...
...
@@ -182,35 +182,42 @@ protected:
};
#endif
class
short_connection
:
public
callbacks
::
s_socket
<
server_socket_base
<
packer
<>
,
unpacker
<>>>
typedef
server_socket_base
<
packer
<>
,
unpacker
<>>
short_socket
;
class
short_connection
:
public
callbacks
::
s_socket
<
short_socket
>
{
private:
typedef
callbacks
::
s_socket
<
server_socket_base
<
ext
::
packer
<>
,
ext
::
unpacker
<>>>
super
;
typedef
server_socket_base
<
ext
::
packer
<>
,
ext
::
unpacker
<>>
raw_socket
;
public:
short_connection
(
i_server
&
server_
)
:
super
(
server_
)
short_connection
(
i_server
&
server_
)
:
callbacks
::
s_socket
<
short_socket
>
(
server_
)
{
//register msg handling from inside of the socket, it also can be done from outside of the socket, see client for more details
//since we're in the socket, so the 'raw_socket* socket' actually is 'this'
//in xxxx callback, do not call super::xxxx, call raw_socket::xxxx instead, otherwise, dead loop will occur.
//in this demo, the raw_socket is 'server_socket_base<ext::packer<>, ext::unpacker<>>', it is defined by the s_socket.
//since we're in the socket, so the 'short_socket* socket' actually is 'this'
//in xxxx callback, do not call callbacks::s_socket<short_socket>::xxxx, call short_socket::xxxx instead, otherwise, dead loop will occur.
#ifdef ASCS_SYNC_DISPATCH
//do not hold msg_can for further usage, return from on_msg as quickly as possible
//access msg_can freely within this callback, it's always thread safe.
register_on_msg
([
this
](
raw_socket
*
socket
,
std
::
list
<
out_msg_type
>&
msg_can
)
{
auto
re
=
raw_socket
::
on_msg
(
msg_can
);
socket
->
force_shutdown
();
return
re
;});
register_on_msg
([
this
](
short_socket
*
socket
,
std
::
list
<
out_msg_type
>&
msg_can
)
{
return
handle_msg_and_shutdown
(
socket
,
msg_can
)
;});
#endif
#ifdef ASCS_DISPATCH_BATCH_MSG
//do not hold msg_can for further usage, access msg_can and return from on_msg_handle as quickly as possible
//can only access msg_can via functions that marked as 'thread safe', if you used non-lock queue, its your responsibility to guarantee
// that new messages will not come until we returned from this callback (for example, pingpong test).
register_on_msg_handle
([
this
](
raw_socket
*
socket
,
out_queue_type
&
msg_can
)
{
auto
re
=
raw_socket
::
on_msg_handle
(
msg_can
);
socket
->
force_shutdown
();
return
re
;});
register_on_msg_handle
([
this
](
short_socket
*
socket
,
out_queue_type
&
msg_can
)
{
return
handle_msg_and_shutdown
(
socket
,
msg_can
)
;});
#else
register_on_msg_handle
([
this
](
raw_socket
*
socket
,
out_msg_type
&
msg
)
{
auto
re
=
raw_socket
::
on_msg_handle
(
msg
);
socket
->
force_shutdown
();
return
re
;});
register_on_msg_handle
([
this
](
short_socket
*
socket
,
out_msg_type
&
msg
)
{
return
handle_msg_and_shutdown
(
socket
,
msg
)
;});
#endif
//register msg handling end
}
private:
#ifdef ASCS_SYNC_DISPATCH
size_t
handle_msg_and_shutdown
(
short_socket
*
socket
,
std
::
list
<
out_msg_type
>&
msg_can
)
{
auto
re
=
short_socket
::
on_msg
(
msg_can
);
socket
->
force_shutdown
();
return
re
;}
#endif
#ifdef ASCS_DISPATCH_BATCH_MSG
size_t
handle_msg_and_shutdown
(
short_socket
*
socket
,
out_queue_type
&
msg_can
)
{
auto
re
=
short_socket
::
on_msg_handle
(
msg_can
);
socket
->
force_shutdown
();
return
re
;}
#else
bool
handle_msg_and_shutdown
(
short_socket
*
socket
,
out_msg_type
&
msg
)
{
auto
re
=
short_socket
::
on_msg_handle
(
msg
);
socket
->
force_shutdown
();
return
re
;}
#endif
};
void
dump_io_context_refs
(
service_pump
&
sp
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录