GCC Code Coverage Report


Directory: ./
File: libs/beast2/include/boost/beast2/server/route_handler_asio.hpp
Date: 2025-12-03 02:12:11
Exec Total Coverage
Lines: 3 11 27.3%
Functions: 1 6 16.7%
Branches: 0 3 0.0%

Line Branch Exec Source
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 ResponseAsio<AsyncStream>::
48 do_post()
49 {
50 asio::post(
51 stream.get_executor(),
52 [&]
53 {
54 if(task_->invoke())
55 return;
56 do_post();
57 });
58 }
59
60 } // beast2
61 } // boost
62
63 #endif
64