LCOV - code coverage report
Current view: top level - boost/beast2/server - route_handler_asio.hpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 27.3 % 11 3
Test Date: 2025-12-03 02:12:11 Functions: 16.7 % 6 1

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2025 Vinnie Falco (vinnie dot falco at gmail dot com)
       3              : //
       4              : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       5              : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       6              : //
       7              : // Official repository: https://github.com/cppalliance/beast2
       8              : //
       9              : 
      10              : #ifndef BOOST_BEAST2_SERVER_ROUTE_HANDLER_ASIO_HPP
      11              : #define BOOST_BEAST2_SERVER_ROUTE_HANDLER_ASIO_HPP
      12              : 
      13              : #include <boost/beast2/detail/config.hpp>
      14              : #include <boost/http_proto/server/route_handler.hpp>
      15              : #include <boost/asio/post.hpp>
      16              : #include <type_traits>
      17              : 
      18              : namespace boost {
      19              : namespace beast2 {
      20              : 
      21              : /** Response object for Asio HTTP route handlers
      22              : */
      23              : template<class AsyncStream>
      24              : class ResponseAsio : public http_proto::Response
      25              : {
      26              : public:
      27              :     using stream_type = typename std::decay<AsyncStream>::type;
      28              : 
      29              :     AsyncStream stream;
      30              : 
      31              :     template<class... Args>
      32              :     explicit
      33            1 :     ResponseAsio(
      34              :         Args&&... args)
      35            1 :         : stream(std::forward<Args>(args)...)
      36              :     {
      37            1 :     }
      38              : 
      39              : private:
      40              :     void do_post() override;
      41              : };
      42              : 
      43              : //-----------------------------------------------
      44              : 
      45              : template<class AsyncStream>
      46              : void
      47            0 : ResponseAsio<AsyncStream>::
      48              : do_post()
      49              : {
      50            0 :     asio::post(
      51            0 :         stream.get_executor(),
      52            0 :         [&]
      53              :         {
      54            0 :             if(task_->invoke())
      55            0 :                 return;
      56            0 :             do_post();
      57              :         });
      58            0 : }
      59              : 
      60              : } // beast2
      61              : } // boost
      62              : 
      63              : #endif
        

Generated by: LCOV version 2.1