summaryrefslogtreecommitdiffhomepage
path: root/include/ocl
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2026-03-04 08:55:10 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2026-03-04 08:55:10 +0100
commit4b2b47d6edc8c8dd75f260fed3286f5dc4fe9374 (patch)
treea4b19757f1db8646a7e80eee9471c008d5d81b07 /include/ocl
parentafda75faa95d7c52d73acb9fbf615831cb6dee1a (diff)
feat: core: add ASIO example and new IOC helper 'run_loop'.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include/ocl')
-rw-r--r--include/ocl/asio.hpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/ocl/asio.hpp b/include/ocl/asio.hpp
index c1e304d..1e4abf5 100644
--- a/include/ocl/asio.hpp
+++ b/include/ocl/asio.hpp
@@ -12,6 +12,7 @@
#else
+#include <boost/asio/strand.hpp>
#include <boost/asio/co_spawn.hpp>
#include <boost/asio/detached.hpp>
#include <boost/asio/io_context.hpp>
@@ -20,4 +21,24 @@
#endif
+namespace ocl::asio
+{
+ using io_context = boost::asio::io_context;
+ using run_pred_type = void(*)();
+
+ template <run_pred_type IOCPred>
+ inline void run_loop(io_context& ioc)
+ {
+ try
+ {
+ ioc.run();
+ }
+ catch (...)
+ {
+ IOCPred();
+ }
+ }
+
+} // namespace ocl
+
#endif