未验证 提交 5fe97469 编写于 作者: Y Yu Yang 提交者: GitHub

Merge pull request #5587 from reyoung/feature/fix_gpu_compile_on_linux

Fix GPU Compile on Linux
...@@ -27,11 +27,12 @@ namespace platform { ...@@ -27,11 +27,12 @@ namespace platform {
This wrap is a hack to avoid this bug. This wrap is a hack to avoid this bug.
*/ */
template <class Callable, class... Args> template <typename Callable, typename... Args>
inline void call_once(std::once_flag& flag, Callable&& f, Args&&... args) { inline void call_once(std::once_flag& flag, Callable&& f, Args&&... args) {
bool good = false; bool good = false;
std::exception ex; std::exception ex;
std::call_once(flag, [&]() { std::call_once(flag,
[&](Args&&... args) {
try { try {
f(args...); f(args...);
good = true; good = true;
...@@ -40,7 +41,8 @@ inline void call_once(std::once_flag& flag, Callable&& f, Args&&... args) { ...@@ -40,7 +41,8 @@ inline void call_once(std::once_flag& flag, Callable&& f, Args&&... args) {
} catch (...) { } catch (...) {
ex = std::runtime_error("excption caught in call_once"); ex = std::runtime_error("excption caught in call_once");
} }
}); },
args...);
if (!good) { if (!good) {
throw std::exception(ex); throw std::exception(ex);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册