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 --- example/allocator_op_example/example.cpp | 14 +++++++------- example/asio_example/example.cpp | 17 ++++++++--------- example/asio_example_2/example.cpp | 14 +++++++------- 3 files changed, 22 insertions(+), 23 deletions(-) (limited to 'example') diff --git a/example/allocator_op_example/example.cpp b/example/allocator_op_example/example.cpp index 7c521fd..bd34955 100644 --- a/example/allocator_op_example/example.cpp +++ b/example/allocator_op_example/example.cpp @@ -23,11 +23,11 @@ int task() int main() { - auto ret = std::async(std::launch::deferred, task); - auto ret2 = std::async(std::launch::deferred, task); - auto ret3 = std::async(std::launch::deferred, task); - - ret.get(); - ret2.get(); - ret3.get(); + auto ret = std::async(std::launch::deferred, task); + auto ret2 = std::async(std::launch::deferred, task); + auto ret3 = std::async(std::launch::deferred, task); + + ret.get(); + ret2.get(); + ret3.get(); } diff --git a/example/asio_example/example.cpp b/example/asio_example/example.cpp index d5abe0a..7b7fc16 100644 --- a/example/asio_example/example.cpp +++ b/example/asio_example/example.cpp @@ -8,9 +8,9 @@ #include #include -constexpr long int operator ""_USD(long double n) +constexpr long int operator""_USD(long double n) { - return n * 1000.0; + return n * 1000.0; } /// @brief Wrap OCL in ASIO calls. @@ -19,19 +19,18 @@ int main() boost::asio::io_context ioc{1}; auto spawn_strand = boost::asio::make_strand(ioc); - ocl::allocator int_alloc; + ocl::allocator int_alloc; - boost::asio::co_spawn(spawn_strand, [&int_alloc]() -> boost::asio::awaitable { + boost::asio::co_spawn(spawn_strand, [&int_alloc]() -> boost::asio::awaitable { auto balance = int_alloc.construct_array<1>(); *balance = operator ""_USD(150); ocl::io::println("Balance USD: ", *balance); - co_return; - }, boost::asio::detached); + co_return; }, boost::asio::detached); - auto balances = int_alloc.construct_array<5>(); + auto balances = int_alloc.construct_array<5>(); - ocl::asio::run<[]() { (void)0; }>(ioc); + ocl::asio::run<[]() { (void)0; }>(ioc); - return EXIT_SUCCESS; + return EXIT_SUCCESS; } diff --git a/example/asio_example_2/example.cpp b/example/asio_example_2/example.cpp index c3bfeef..42410d7 100644 --- a/example/asio_example_2/example.cpp +++ b/example/asio_example_2/example.cpp @@ -9,18 +9,18 @@ #include #include -namespace asio = ::boost::asio; +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(); + asio::io_context ioc; + process::process proc(ioc, "/usr/bin/g++", {"--version"}, process::v2::process_stdio{{/* in to default */}, {}, nullptr}); - ocl::asio::run<[]() { (void)0; }>(ioc); + proc.wait(); - return EXIT_SUCCESS; + ocl::asio::run<[]() { (void)0; }>(ioc); + + return EXIT_SUCCESS; } -- cgit v1.2.3