Skip to content

Commit 45e2127

Browse files
committed
guard coroutine code with BOOST_CAPY_HAS_CORO
1 parent fb5c0f0 commit 45e2127

File tree

10 files changed

+38
-7
lines changed

10 files changed

+38
-7
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,9 +865,9 @@ jobs:
865865
- name: Clone Boost.Http.Proto
866866
uses: actions/checkout@v3
867867
with:
868-
repository: cppalliance/http_proto
868+
repository: ashtum/http_proto
869869
path: http-proto-root
870-
ref: develop
870+
ref: fix-symbol-visibility
871871

872872
- name: Clone Boost.Buffers
873873
uses: actions/checkout@v3

example/client/burl/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
# Official repository: https://github.com/cppalliance/beast2
88
#
99

10+
if(NOT cxx_std_20 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
11+
return()
12+
endif()
13+
1014
file(GLOB_RECURSE PFILES CONFIGURE_DEPENDS *.cpp *.hpp
1115
CMakeLists.txt
1216
Jamfile)

example/client/burl/multipart_form.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111

1212
#include <boost/buffers/copy.hpp>
1313
#include <boost/buffers/slice.hpp>
14-
#include <boost/http_proto/file.hpp>
14+
#include <boost/capy/file.hpp>
1515
#include <boost/system/system_error.hpp>
1616

1717
#include <filesystem>
1818
#include <random>
1919

20+
namespace capy = boost::capy;
2021
namespace core = boost::core;
2122
namespace fs = std::filesystem;
2223
using system_error = boost::system::system_error;
@@ -171,9 +172,9 @@ multipart_form::source::on_read(buffers::mutable_buffer mb)
171172

172173
auto read = [&](const std::string& path, uint64_t size)
173174
{
174-
http_proto::file file;
175+
capy::file file;
175176

176-
file.open(path.c_str(), http_proto::file_mode::read, rs.ec);
177+
file.open(path.c_str(), capy::file_mode::read, rs.ec);
177178
if(rs.ec)
178179
return false;
179180

example/client/jsonrpc/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
# Official repository: https://github.com/cppalliance/beast2
88
#
99

10+
if(NOT cxx_std_20 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
11+
return()
12+
endif()
13+
1014
file(GLOB_RECURSE PFILES CONFIGURE_DEPENDS *.cpp *.hpp
1115
CMakeLists.txt
1216
Jamfile)

example/cpp20/co_spawn/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
# Official repository: https://github.com/cppalliance/beast2
88
#
99

10+
if(NOT cxx_std_20 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
11+
return()
12+
endif()
13+
1014
file(GLOB_RECURSE PFILES CONFIGURE_DEPENDS *.cpp *.hpp
1115
CMakeLists.txt
1216
Jamfile)

example/cpp20/co_spawn/Jamfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# Official repository: https://github.com/cppalliance/beast2
88
#
99

10+
import config : requires ;
11+
1012
using openssl ;
1113
import ac ;
1214

@@ -32,4 +34,8 @@ project
3234

3335
exe get :
3436
[ glob *.cpp ]
37+
: requirements
38+
[ requires
39+
cxx20_hdr_coroutine
40+
]
3541
;

example/server/Jamfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ project
2020
: requirements
2121
<library>/boost/beast2//boost_beast2
2222
<library>/boost/url//boost_url
23+
<library>/boost/json//boost_json
2324
[ ac.check-library /boost/capy//boost_capy_zlib : <library>/boost/capy//boost_capy_zlib : ]
2425
[ ac.check-library /boost/capy//boost_capy_brotli : <library>/boost/capy//boost_capy_brotli : ]
2526
[ ac.check-library /openssl//ssl : <library>/openssl//ssl/<link>shared : <build>no ]

example/server/main.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,15 @@ struct do_json_rpc
136136
}
137137
};
138138

139+
#ifdef BOOST_CAPY_HAS_CORO
139140
auto
140141
do_request(
141142
http::route_params& rp) ->
142143
capy::task<http::route_result>
143144
{
144145
co_return http::route::next;
145146
}
147+
#endif
146148

147149
int server_main( int argc, char* argv[] )
148150
{
@@ -168,7 +170,9 @@ int server_main( int argc, char* argv[] )
168170
http::cors_options opts;
169171
opts.allowedHeaders = "Content-Type";
170172

173+
#ifdef BOOST_CAPY_HAS_CORO
171174
srv.wwwroot.use( http::co_route( do_request ) );
175+
#endif
172176

173177
srv.wwwroot.use("/rpc",
174178
http::cors(opts),
@@ -178,7 +182,7 @@ int server_main( int argc, char* argv[] )
178182
{
179183
if(rp.parser.is_complete())
180184
{
181-
auto s = rp.parser.body();
185+
// auto s = rp.parser.body();
182186
return http::route::next;
183187
}
184188
return http::route::next;

include/boost/beast2/server/route_handler_asio.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class asio_route_params
3939
}
4040

4141
private:
42+
#ifdef BOOST_CAPY_HAS_CORO
4243
auto
4344
spawn(
4445
capy::task<http::route_result> t) ->
@@ -63,6 +64,7 @@ class asio_route_params
6364
});
6465
});
6566
}
67+
#endif
6668

6769
void do_post() override;
6870
};

include/boost/beast2/spawn.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
#ifndef BOOST_BEAST2_SPAWN_HPP
1111
#define BOOST_BEAST2_SPAWN_HPP
1212

13-
#include <boost/beast2/detail/config.hpp>
1413
#include <boost/capy/task.hpp>
14+
15+
#ifdef BOOST_CAPY_HAS_CORO
16+
17+
#include <boost/beast2/detail/config.hpp>
1518
#include <boost/asio/co_spawn.hpp>
1619
#include <boost/asio/detached.hpp>
1720
#include <boost/asio/any_io_executor.hpp>
@@ -78,3 +81,5 @@ auto spawn(
7881
} // boost
7982

8083
#endif
84+
85+
#endif

0 commit comments

Comments
 (0)