summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2026-03-18 06:51:01 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2026-03-18 06:51:01 +0100
commit0745b058c1fd373a10210c8d9397008b145d82bd (patch)
tree506b6d858b49e5dcc1e75e8e4f7a705553722668 /include
parente3c44bac404812920f6e19285bd126b087f3bc39 (diff)
[CHORE] Update examples for Asio and AllocOp.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/ocl/alloc_op.hpp4
-rw-r--r--include/ocl/asio.hpp22
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());
}
}