From e52916cec7db2c3294abd7a9b45a1e708627b238 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 9 Mar 2026 05:22:54 +0100 Subject: [CHORE] Update example.cpp unit. Signed-off-by: Amlal El Mahrouss --- example/asio_example_2/CMakeLists.txt | 21 +++++++++++++++++++++ example/asio_example_2/example.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 example/asio_example_2/CMakeLists.txt create mode 100644 example/asio_example_2/example.cpp (limited to 'example') diff --git a/example/asio_example_2/CMakeLists.txt b/example/asio_example_2/CMakeLists.txt new file mode 100644 index 0000000..7ccfabe --- /dev/null +++ b/example/asio_example_2/CMakeLists.txt @@ -0,0 +1,21 @@ +# (C) 2026 Amlal El Mahrouss + +cmake_minimum_required(VERSION 3.15...3.31) + +project( + AsioExample + VERSION 1.0 + LANGUAGES CXX) + +find_package(Boost REQUIRED) + +add_executable(AsioExample2 example.cpp) + +set_property(TARGET AsioExample2 PROPERTY CXX_STANDARD 20) +target_include_directories(AsioExample2 PUBLIC ../../include/) + +if (NOT DEFINED LINUX) +target_link_libraries(AsioExample2 PRIVATE Boost Core Asio Process) +else() +target_link_libraries(AsioExample2 PRIVATE boost_process) +endif () diff --git a/example/asio_example_2/example.cpp b/example/asio_example_2/example.cpp new file mode 100644 index 0000000..f16aa1e --- /dev/null +++ b/example/asio_example_2/example.cpp @@ -0,0 +1,31 @@ +// Copyright 2026, Amlal El Mahrouss (amlal@nekernel.org) +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// Official repository: https://git.ocl.nekernel.org/core + +#include +#include +#include +#include +#include + +constexpr long int operator ""_USD(long double n) +{ + return n * 1000.0; +} + +namespace asio = ::boost::asio; +namespace process = ::boost::process; + +/// @brief Wrap OCL in ASIO calls. +int main() +{ + asio::io_context ioc; + process::process proc(ioc, "/usr/bin/g++", {"--version"}, process::v2::process_stdio{{ /* in to default */}, {}, nullptr}); + + proc.wait(); + + ocl::asio::run<[]() { (void)0; }>(ioc); + + return EXIT_SUCCESS; +} -- cgit v1.2.3