Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Oneflow-Inc
oneflow
提交
fb3b79b0
O
oneflow
项目概览
Oneflow-Inc
/
oneflow
上一次同步 2 年多
通知
13
Star
2733
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oneflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fb3b79b0
编写于
10月 15, 2017
作者:
W
willzhang4a58
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine mutex in read callback
Former-commit-id:
78132f33
上级
6736e8c4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
21 deletion
+25
-21
oneflow/core/comm_network/epoll/epoll_data_comm_network.cpp
oneflow/core/comm_network/epoll/epoll_data_comm_network.cpp
+23
-20
oneflow/core/comm_network/epoll/epoll_data_comm_network.h
oneflow/core/comm_network/epoll/epoll_data_comm_network.h
+2
-1
未找到文件。
oneflow/core/comm_network/epoll/epoll_data_comm_network.cpp
浏览文件 @
fb3b79b0
...
@@ -117,6 +117,7 @@ void EpollDataCommNet::AddReadCallBack(void* actor_read_id, void* read_id,
...
@@ -117,6 +117,7 @@ void EpollDataCommNet::AddReadCallBack(void* actor_read_id, void* read_id,
break
;
break
;
}
else
{
}
else
{
actor_read_ctx
->
read_ctx_list
.
back
()
->
cbl
.
push_back
(
callback
);
actor_read_ctx
->
read_ctx_list
.
back
()
->
cbl
.
push_back
(
callback
);
return
;
}
}
}
while
(
0
);
}
while
(
0
);
callback
();
callback
();
...
@@ -125,7 +126,10 @@ void EpollDataCommNet::AddReadCallBack(void* actor_read_id, void* read_id,
...
@@ -125,7 +126,10 @@ void EpollDataCommNet::AddReadCallBack(void* actor_read_id, void* read_id,
void
EpollDataCommNet
::
AddReadCallBackDone
(
void
*
actor_read_id
,
void
*
read_id
)
{
void
EpollDataCommNet
::
AddReadCallBackDone
(
void
*
actor_read_id
,
void
*
read_id
)
{
auto
actor_read_ctx
=
static_cast
<
ActorReadContext
*>
(
actor_read_id
);
auto
actor_read_ctx
=
static_cast
<
ActorReadContext
*>
(
actor_read_id
);
ReadContext
*
read_ctx
=
static_cast
<
ReadContext
*>
(
read_id
);
ReadContext
*
read_ctx
=
static_cast
<
ReadContext
*>
(
read_id
);
IncreaseDoneCnt
(
actor_read_ctx
,
read_ctx
);
if
(
IncreaseDoneCnt
(
read_ctx
)
==
2
)
{
FinishOneReadContext
(
actor_read_ctx
,
read_ctx
);
delete
read_ctx
;
}
}
}
void
EpollDataCommNet
::
ReadDone
(
void
*
read_done_id
)
{
void
EpollDataCommNet
::
ReadDone
(
void
*
read_done_id
)
{
...
@@ -134,27 +138,26 @@ void EpollDataCommNet::ReadDone(void* read_done_id) {
...
@@ -134,27 +138,26 @@ void EpollDataCommNet::ReadDone(void* read_done_id) {
auto
actor_read_ctx
=
std
::
get
<
0
>
(
*
parsed_read_done_id
);
auto
actor_read_ctx
=
std
::
get
<
0
>
(
*
parsed_read_done_id
);
auto
read_ctx
=
std
::
get
<
1
>
(
*
parsed_read_done_id
);
auto
read_ctx
=
std
::
get
<
1
>
(
*
parsed_read_done_id
);
delete
parsed_read_done_id
;
delete
parsed_read_done_id
;
IncreaseDoneCnt
(
actor_read_ctx
,
read_ctx
);
if
(
IncreaseDoneCnt
(
read_ctx
)
==
2
)
{
}
{
std
::
unique_lock
<
std
::
mutex
>
lck
(
actor_read_ctx
->
read_ctx_list_mtx
);
void
EpollDataCommNet
::
IncreaseDoneCnt
(
ActorReadContext
*
actor_read_ctx
,
FinishOneReadContext
(
actor_read_ctx
,
read_ctx
);
ReadContext
*
read_ctx
)
{
do
{
std
::
unique_lock
<
std
::
mutex
>
lck
(
read_ctx
->
done_cnt_mtx
);
read_ctx
->
done_cnt
+=
1
;
if
(
read_ctx
->
done_cnt
==
2
)
{
break
;
}
else
{
return
;
}
}
}
while
(
0
);
delete
read_ctx
;
{
std
::
unique_lock
<
std
::
mutex
>
lck
(
actor_read_ctx
->
read_ctx_list_mtx
);
CHECK_EQ
(
actor_read_ctx
->
read_ctx_list
.
front
(),
read_ctx
);
actor_read_ctx
->
read_ctx_list
.
pop_front
();
for
(
std
::
function
<
void
()
>&
callback
:
read_ctx
->
cbl
)
{
callback
();
}
}
}
delete
read_ctx
;
}
int8_t
EpollDataCommNet
::
IncreaseDoneCnt
(
ReadContext
*
read_ctx
)
{
std
::
unique_lock
<
std
::
mutex
>
lck
(
read_ctx
->
done_cnt_mtx
);
read_ctx
->
done_cnt
+=
1
;
return
read_ctx
->
done_cnt
;
}
void
EpollDataCommNet
::
FinishOneReadContext
(
ActorReadContext
*
actor_read_ctx
,
ReadContext
*
read_ctx
)
{
CHECK_EQ
(
actor_read_ctx
->
read_ctx_list
.
front
(),
read_ctx
);
actor_read_ctx
->
read_ctx_list
.
pop_front
();
for
(
std
::
function
<
void
()
>&
callback
:
read_ctx
->
cbl
)
{
callback
();
}
}
}
void
EpollDataCommNet
::
SendActorMsg
(
int64_t
dst_machine_id
,
void
EpollDataCommNet
::
SendActorMsg
(
int64_t
dst_machine_id
,
...
...
oneflow/core/comm_network/epoll/epoll_data_comm_network.h
浏览文件 @
fb3b79b0
...
@@ -47,7 +47,8 @@ class EpollDataCommNet final : public DataCommNet {
...
@@ -47,7 +47,8 @@ class EpollDataCommNet final : public DataCommNet {
std
::
list
<
ReadContext
*>
read_ctx_list
;
std
::
list
<
ReadContext
*>
read_ctx_list
;
};
};
EpollDataCommNet
();
EpollDataCommNet
();
void
IncreaseDoneCnt
(
ActorReadContext
*
actor_read_ctx
,
ReadContext
*
read_ctx
);
int8_t
IncreaseDoneCnt
(
ReadContext
*
);
void
FinishOneReadContext
(
ActorReadContext
*
,
ReadContext
*
);
void
InitSockets
();
void
InitSockets
();
SocketHelper
*
GetSocketHelper
(
int64_t
machine_id
);
SocketHelper
*
GetSocketHelper
(
int64_t
machine_id
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录