Fix GPU Compile on Linux

mobile_baidu
Yang Yu 7 years ago
parent 1c31bb9459
commit 174050277a

@ -27,20 +27,22 @@ 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,
try { [&](Args&&... args) {
f(args...); try {
good = true; f(args...);
} catch (const std::exception& e) { good = true;
ex = e; } catch (const std::exception& e) {
} catch (...) { ex = e;
ex = std::runtime_error("excption caught in call_once"); } catch (...) {
} ex = std::runtime_error("excption caught in call_once");
}); }
},
args...);
if (!good) { if (!good) {
throw std::exception(ex); throw std::exception(ex);
} }

Loading…
Cancel
Save