diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2026-03-09 05:25:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-09 05:25:11 +0100 |
| commit | 07441b4031482ed85d3a5fe51e8e76bbee50c42e (patch) | |
| tree | 617b7aa388cefad4a02d8b7fa373477f08537cdc /example | |
| parent | 5bac3b38e326598cc85053a0e5c61db7010ed049 (diff) | |
| parent | 4ceb12b15985f705c58d3f97ff3cf97413aae64a (diff) | |
Merge pull request #46 from ocl-foss-org/another-asio-example
[CHORE] New example of OCL.Core + Boost.{Process, Asio}
Diffstat (limited to 'example')
| -rw-r--r-- | example/asio_example_2/CMakeLists.txt | 21 | ||||
| -rw-r--r-- | example/asio_example_2/example.cpp | 26 |
2 files changed, 47 insertions, 0 deletions
diff --git a/example/asio_example_2/CMakeLists.txt b/example/asio_example_2/CMakeLists.txt new file mode 100644 index 0000000..a26fbfc --- /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( + AsioExample2 + 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..c3bfeef --- /dev/null +++ b/example/asio_example_2/example.cpp @@ -0,0 +1,26 @@ +// 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 <ocl/print.hpp> +#include <ocl/asio.hpp> +#include <ocl/allocator_op.hpp> +#include <future> +#include <boost/process.hpp> + +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; +} |
