diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/ocl/alloc_op.hpp | 4 | ||||
| -rw-r--r-- | include/ocl/asio.hpp | 22 |
2 files changed, 21 insertions, 5 deletions
diff --git a/include/ocl/alloc_op.hpp b/include/ocl/alloc_op.hpp index d7f81fe..05d9ed0 100644 --- a/include/ocl/alloc_op.hpp +++ b/include/ocl/alloc_op.hpp @@ -76,7 +76,7 @@ namespace ocl template <typename... VarType> auto construct_var(VarType&&... args) { - static AllocNew alloc; + static AllocNew alloc; typename AllocNew::lock_type lt{alloc.m_}; return std::shared_ptr<RetType>(alloc.template var_alloc<VarType...>(std::forward<VarType...>(args)...), AllocDelete{}); } @@ -84,7 +84,7 @@ namespace ocl template <std::size_t N> auto construct_array() { - static AllocNew alloc; + static AllocNew alloc; typename AllocNew::lock_type lt{alloc.m_}; return std::shared_ptr<RetType>(alloc.template array_alloc<N>(), AllocDelete{}); } diff --git a/include/ocl/asio.hpp b/include/ocl/asio.hpp index a4c504b..ab7ee4d 100644 --- a/include/ocl/asio.hpp +++ b/include/ocl/asio.hpp @@ -19,6 +19,7 @@ #include <boost/asio/io_context.hpp> #include <boost/asio/write.hpp> #include <boost/asio/read.hpp> +#include <ocl/print.hpp> #endif @@ -28,16 +29,31 @@ namespace ocl::asio using io_context_type = boost::asio::io_context; using run_pred_type = void (*)(); - template <run_pred_type IOCPred> + template <class IOCPred> inline void run(io_context_type& ioc) { try { ioc.run(); } - catch (...) + catch (const std::exception& e) { - IOCPred(); + IOCPred{}(); + ocl::io::println(e.what()); + } + } + + template <run_pred_type IOCFn> + inline void run(io_context_type& ioc) + { + try + { + ioc.run(); + } + catch (const std::exception& e) + { + IOCFn(); + ocl::io::println(e.what()); } } |
