From 0745b058c1fd373a10210c8d9397008b145d82bd Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 18 Mar 2026 06:51:01 +0100 Subject: [CHORE] Update examples for Asio and AllocOp. Signed-off-by: Amlal El Mahrouss --- include/ocl/alloc_op.hpp | 4 ++-- include/ocl/asio.hpp | 22 +++++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) (limited to 'include') 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 auto construct_var(VarType&&... args) { - static AllocNew alloc; + static AllocNew alloc; typename AllocNew::lock_type lt{alloc.m_}; return std::shared_ptr(alloc.template var_alloc(std::forward(args)...), AllocDelete{}); } @@ -84,7 +84,7 @@ namespace ocl template auto construct_array() { - static AllocNew alloc; + static AllocNew alloc; typename AllocNew::lock_type lt{alloc.m_}; return std::shared_ptr(alloc.template array_alloc(), 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 #include #include +#include #endif @@ -28,16 +29,31 @@ namespace ocl::asio using io_context_type = boost::asio::io_context; using run_pred_type = void (*)(); - template + template inline void run(io_context_type& ioc) { try { ioc.run(); } - catch (...) + catch (const std::exception& e) { - IOCPred(); + IOCPred{}(); + ocl::io::println(e.what()); + } + } + + template + inline void run(io_context_type& ioc) + { + try + { + ioc.run(); + } + catch (const std::exception& e) + { + IOCFn(); + ocl::io::println(e.what()); } } -- cgit v1.2.3