Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
71f6b56c
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
71f6b56c
编写于
1月 24, 2022
作者:
H
HexToString
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix async while
上级
a1e33e46
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
150 addition
and
0 deletion
+150
-0
core/predictor/framework/thread_mutex.cpp
core/predictor/framework/thread_mutex.cpp
+99
-0
core/predictor/framework/thread_mutex.h
core/predictor/framework/thread_mutex.h
+51
-0
未找到文件。
core/predictor/framework/thread_mutex.cpp
0 → 100755
浏览文件 @
71f6b56c
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "core/predictor/framework/thread_mutex.h"
#include "core/predictor/common/inner_common.h"
namespace
baidu
{
namespace
paddle_serving
{
namespace
predictor
{
int
ThreadMutex
::
initialize
()
{
if
(
THREAD_KEY_CREATE
(
&
_bspec_key_mutex
,
NULL
)
!=
0
)
{
LOG
(
ERROR
)
<<
"unable to create thread_key of thrd_data"
;
return
-
1
;
}
if
(
THREAD_SETSPECIFIC
(
_bspec_key_mutex
,
NULL
)
!=
0
)
{
LOG
(
ERROR
)
<<
"failed initialize bsepecific key to null"
;
return
-
1
;
}
if
(
THREAD_KEY_CREATE
(
&
_bspec_key_cond
,
NULL
)
!=
0
)
{
LOG
(
ERROR
)
<<
"unable to create thread_key of thrd_data"
;
return
-
1
;
}
if
(
THREAD_SETSPECIFIC
(
_bspec_key_cond
,
NULL
)
!=
0
)
{
LOG
(
ERROR
)
<<
"failed initialize bsepecific key to null"
;
return
-
1
;
}
return
0
;
}
int
ThreadMutex
::
thread_initialize
()
{
THREAD_MUTEX_T
*
mutex_ptr
=
new
THREAD_MUTEX_T
();
THREAD_MUTEX_INIT
(
mutex_ptr
,
NULL
);
if
(
THREAD_SETSPECIFIC
(
_bspec_key_mutex
,
mutex_ptr
)
!=
0
)
{
LOG
(
ERROR
)
<<
"unable to set the thrd_data"
;
delete
mutex_ptr
;
return
-
1
;
}
THREAD_COND_T
*
cont_ptr
=
new
THREAD_COND_T
();
THREAD_COND_INIT
(
cont_ptr
,
NULL
);
if
(
THREAD_SETSPECIFIC
(
_bspec_key_cond
,
cont_ptr
)
!=
0
)
{
LOG
(
ERROR
)
<<
"unable to set the thrd_data"
;
delete
cont_ptr
;
return
-
1
;
}
LOG
(
WARNING
)
<<
"Succ thread initialize ThreadMutex"
;
return
0
;
}
int
ThreadMutex
::
thread_finalize
()
{
THREAD_MUTEX_T
*
mutex_ptr
=
(
THREAD_MUTEX_T
*
)
THREAD_GETSPECIFIC
(
_bspec_key_mutex
);
if
(
mutex_ptr
!=
NULL
)
{
THREAD_MUTEX_DESTROY
(
mutex_ptr
);
delete
mutex_ptr
;
}
THREAD_COND_T
*
cont_ptr
=
(
THREAD_COND_T
*
)
THREAD_GETSPECIFIC
(
_bspec_key_cond
);
if
(
cont_ptr
!=
NULL
)
{
THREAD_COND_DESTROY
(
cont_ptr
);
delete
cont_ptr
;
}
LOG
(
WARNING
)
<<
"Succ thread initialize ThreadMutex"
;
return
0
;
}
int
ThreadMutex
::
finalize
()
{
THREAD_KEY_DELETE
(
_bspec_key_mutex
);
THREAD_KEY_DELETE
(
_bspec_key_cond
);
return
0
;
}
THREAD_MUTEX_T
*
ThreadMutex
::
get_thread_mutex_ptr
()
{
THREAD_MUTEX_T
*
mutex_ptr
=
(
THREAD_MUTEX_T
*
)
THREAD_GETSPECIFIC
(
_bspec_key_mutex
);
return
mutex_ptr
;
}
THREAD_COND_T
*
ThreadMutex
::
get_thread_cond_ptr
()
{
THREAD_COND_T
*
cont_ptr
=
(
THREAD_COND_T
*
)
THREAD_GETSPECIFIC
(
_bspec_key_cond
);
return
cont_ptr
;
}
}
// namespace predictor
}
// namespace paddle_serving
}
// namespace baidu
core/predictor/framework/thread_mutex.h
0 → 100644
浏览文件 @
71f6b56c
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include "core/predictor/common/inner_common.h"
namespace
baidu
{
namespace
paddle_serving
{
namespace
predictor
{
class
ThreadMutex
{
public:
ThreadMutex
()
{}
static
ThreadMutex
&
instance
()
{
static
ThreadMutex
thread_mutex
;
return
thread_mutex
;
}
int
initialize
();
int
thread_initialize
();
THREAD_MUTEX_T
*
get_thread_mutex_ptr
();
THREAD_COND_T
*
get_thread_cond_ptr
();
int
thread_finalize
();
int
finalize
();
private:
THREAD_KEY_T
_bspec_key_mutex
;
THREAD_KEY_T
_bspec_key_cond
;
};
}
// namespace predictor
}
// namespace paddle_serving
}
// namespace baidu
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录