Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
youngwolf
ascs
提交
a6ba7c5b
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 搜索 >>
提交
a6ba7c5b
编写于
11月 14, 2023
作者:
Y
youngwolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Compromise with c++17 and c++20 (just in MSVC).
上级
d791e25b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
3 deletion
+23
-3
examples/echo_server/echo_server.cpp
examples/echo_server/echo_server.cpp
+4
-0
include/ascs/object_pool.h
include/ascs/object_pool.h
+15
-3
include/ascs/tracked_executor.h
include/ascs/tracked_executor.h
+4
-0
未找到文件。
examples/echo_server/echo_server.cpp
浏览文件 @
a6ba7c5b
...
...
@@ -67,7 +67,11 @@ using namespace ascs::ext;
//under the default behavior, each tcp::socket has their own packer, and cause memory waste
//at here, we make each echo_socket use the same global packer for memory saving
//notice: do not do this for unpacker, because unpacker has member variables and can't share each other
#if _MSVC_LANG > 201703L
auto
global_packer
=
std
::
make_shared
<
ASCS_DEFAULT_PACKER
>
();
#else
auto
global_packer
(
std
::
make_shared
<
ASCS_DEFAULT_PACKER
>
());
#endif
//demonstrate how to control the type of tcp::server_socket_base::server from template parameter
class
i_echo_server
:
public
i_server
...
...
include/ascs/object_pool.h
浏览文件 @
a6ba7c5b
...
...
@@ -257,7 +257,11 @@ public:
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
invalid_object_can_mutex
);
auto
iter
=
std
::
find_if
(
std
::
begin
(
invalid_object_can
),
std
::
end
(
invalid_object_can
),
[
&
](
object_ctype
&
item
)
{
return
item
->
is_equal_to
(
id
);});
if
(
iter
!=
std
::
end
(
invalid_object_can
)
&&
(
*
iter
).
unique
()
&&
(
*
iter
)
->
obsoleted
())
#if _MSVC_LANG >= 201703L
if
(
iter
!=
std
::
end
(
invalid_object_can
)
&&
1
==
iter
->
use_count
()
&&
(
*
iter
)
->
obsoleted
())
#else
if
(
iter
!=
std
::
end
(
invalid_object_can
)
&&
iter
->
unique
()
&&
(
*
iter
)
->
obsoleted
())
#endif
{
auto
object_ptr
(
std
::
move
(
*
iter
));
invalid_object_can
.
erase
(
iter
);
...
...
@@ -271,7 +275,11 @@ public:
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
invalid_object_can_mutex
);
for
(
auto
iter
=
std
::
begin
(
invalid_object_can
);
iter
!=
std
::
end
(
invalid_object_can
);
++
iter
)
if
((
*
iter
).
unique
()
&&
(
*
iter
)
->
obsoleted
())
#if _MSVC_LANG >= 201703L
if
(
iter
->
use_count
()
&&
(
*
iter
)
->
obsoleted
())
#else
if
(
iter
->
unique
()
&&
(
*
iter
)
->
obsoleted
())
#endif
{
auto
object_ptr
(
std
::
move
(
*
iter
));
invalid_object_can
.
erase
(
iter
);
...
...
@@ -332,7 +340,11 @@ public:
// socket_ptr->set_timer(...);
//}
//then in the future, when invoke the timer handler, the socket has been freed and its this pointer already became wild.
if
((
*
iter
).
unique
()
&&
(
*
iter
)
->
obsoleted
())
#if _MSVC_LANG >= 201703L
if
(
1
==
iter
->
use_count
()
&&
(
*
iter
)
->
obsoleted
())
#else
if
(
iter
->
unique
()
&&
(
*
iter
)
->
obsoleted
())
#endif
{
--
num
;
++
num_affected
;
...
...
include/ascs/tracked_executor.h
浏览文件 @
a6ba7c5b
...
...
@@ -69,7 +69,11 @@ public:
{
auto
ref_holder
(
aci
);
return
[
=
](
const
boost
::
system
::
error_code
&
ec
,
size_t
bytes_transferred
)
{(
void
)
ref_holder
;
handler
(
ec
,
bytes_transferred
);};}
#endif
#if _MSVC_LANG >= 201703L
bool
is_async_calling
()
const
{
return
aci
.
use_count
()
>
1
;}
#else
bool
is_async_calling
()
const
{
return
!
aci
.
unique
();}
#endif
bool
is_last_async_call
()
const
{
return
aci
.
use_count
()
<=
2
;}
//can only be called in callbacks
inline
void
set_async_calling
(
bool
)
{}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录