Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
195c923f
V
VisualDL
项目概览
PaddlePaddle
/
VisualDL
1 年多 前同步成功
通知
88
Star
4655
Fork
642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
V
VisualDL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
195c923f
编写于
11月 24, 2017
作者:
S
superjom
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init concurrency
上级
415eb030
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
77 addition
and
3 deletion
+77
-3
CMakeLists.txt
CMakeLists.txt
+5
-1
visualdl/backend/logic/im.h
visualdl/backend/logic/im.h
+13
-2
visualdl/backend/utils/concurrency.h
visualdl/backend/utils/concurrency.h
+56
-0
visualdl/backend/utils/test_concurrency.cc
visualdl/backend/utils/test_concurrency.cc
+3
-0
未找到文件。
CMakeLists.txt
浏览文件 @
195c923f
...
...
@@ -20,12 +20,16 @@ add_library(sdk ${PROJECT_SOURCE_DIR}/visualdl/backend/logic/sdk.cc)
add_library
(
im
${
PROJECT_SOURCE_DIR
}
/visualdl/backend/logic/im.cc
)
pybind11_add_module
(
core
${
PROJECT_SOURCE_DIR
}
/visualdl/backend/logic/pybind.cc
)
${
PROJECT_SOURCE_DIR
}
/visualdl/backend/logic/pybind.cc
${
PROJECT_SOURCE_DIR
}
/visualdl/backend/utils/filesystem.h
${
PROJECT_SOURCE_DIR
}
/visualdl/backend/utils/concurrency.h
)
target_link_libraries
(
core PRIVATE pybind11::module im storage sdk protobuf glog
)
set_target_properties
(
core PROPERTIES POSITION_INDEPENDENT_CODE TRUE
)
add_executable
(
vl_test
${
PROJECT_SOURCE_DIR
}
/visualdl/backend/test.cc
${
PROJECT_SOURCE_DIR
}
/visualdl/backend/storage/storage_test.cc
${
PROJECT_SOURCE_DIR
}
/visualdl/backend/utils/test_concurrency.cc
${
PROJECT_SOURCE_DIR
}
/visualdl/backend/logic/im_test.cc
)
target_link_libraries
(
vl_test storage im gtest glog protobuf gflags pthread
)
visualdl/backend/logic/im.h
浏览文件 @
195c923f
...
...
@@ -10,8 +10,19 @@
namespace
visualdl
{
/*
* Maintain the Storage singleton in memory, pre-compute some the statical
* information to help visualizaton.
* InformationMaintainer(IM) maintain the Storage singleton in memory,
* pre-compute some the statistical information to help visualizaton.
*
* There should be two processes and each have an IM, one is the web server
* which hold one IM to read the storage, the other is the SDK(python or C++),
* it will get an IM to write latest changes to storage.
*
* An IM have an underlying Storage object, which might be a memory based
* storage or a disk based one, both has the same interfaces those defined by
* class StorageBase.
*
* The SDK's IM will maintain the changes and periodically write to disk, and
* the web server's IM will periodically read latest storage from disk.
*/
class
InformationMaintainer
final
{
public:
...
...
visualdl/backend/utils/concurrency.h
0 → 100644
浏览文件 @
195c923f
#ifndef VISUALDL_BACKEND_UTILS_CONCURRENCY_H
#define VISUALDL_BACKEND_UTILS_CONCURRENCY_H
#include <chrono>
#include <memory>
#include <thread>
#include <vector>
namespace
visualdl
{
namespace
cc
{
/*
* Run a task every `duration` milliseconds.
* Each evoke will start a thread to do this asynchronously.
*/
struct
PeriodExector
{
using
task_t
=
std
::
function
<
void
()
>
;
using
duration_t
=
std
::
chrono
::
milliseconds
;
PeriodExector
&
Global
()
{
static
PeriodExector
exec
;
return
exec
;
}
void
Quit
()
{
// TODO use some conditonal variable to help quit immediately.
quit
=
true
;
}
void
operator
()(
task_t
&&
task
,
duration_t
duration
)
{
auto
task_wrapper
=
[
&
,
task
]
{
while
(
!
quit
)
{
task
();
std
::
this_thread
::
sleep_for
(
duration
);
}
};
threads_
.
emplace_back
(
std
::
thread
(
std
::
move
(
task_wrapper
)));
}
~
PeriodExector
()
{
for
(
auto
&
t
:
threads_
)
{
if
(
t
.
joinable
())
{
t
.
join
();
}
}
}
private:
bool
quit
=
false
;
std
::
vector
<
std
::
thread
>
threads_
;
};
}
// namespace cc
}
// namespace visualdl
#endif
visualdl/backend/utils/test_concurrency.cc
0 → 100644
浏览文件 @
195c923f
#include <gtest/gtest.h>
namespace
visualdl
{}
// namespace visualdl
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录