Skip to content

Commit 8d21045

Browse files
committed
Refactor server to use corosio instead of asio
- Remove obsolete asio-based types (body_read_stream, body_write_stream, read, write, etc.) - Replace router_asio/route_handler_asio with router_corosio/route_handler_corosio - Remove obsolete test stream types - Delete workers.cpp (implementation now fully inline in header) - Update http_server to use corosio io_context - Clean up examples to use new corosio-based API
1 parent 4478c99 commit 8d21045

33 files changed

+513
-4617
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ set(BOOST_SRC_DIR ${DEFAULT_BOOST_SRC_DIR} CACHE STRING "Boost source dir to use
5555
#-------------------------------------------------
5656
# The boost super-project requires one explicit dependency per-line.
5757
set(BOOST_BEAST2_DEPENDENCIES
58-
Boost::asio
58+
Boost::corosio
5959
Boost::assert
6060
Boost::capy
6161
Boost::config
@@ -123,7 +123,7 @@ if (BOOST_BEAST2_IS_ROOT)
123123
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${BOOST_SRC_DIR}/tools/cmake/include")
124124
else ()
125125
# From Boost Package
126-
find_package(Boost REQUIRED COMPONENTS capy http json program_options scope system url)
126+
find_package(Boost REQUIRED COMPONENTS capy corosio http json program_options scope system url)
127127
foreach (BOOST_INCLUDE_LIBRARY ${BOOST_INCLUDE_LIBRARIES})
128128
if (NOT TARGET Boost::${BOOST_INCLUDE_LIBRARY})
129129
add_library(Boost::${BOOST_INCLUDE_LIBRARY} ALIAS Boost::headers)

build/Jamfile

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ project boost/beast2
2828
<link>shared:<define>BOOST_BEAST2_DYN_LINK=1
2929
<link>static:<define>BOOST_BEAST2_STATIC_LINK=1
3030
<toolset>clang-win:<cxxflags>"-Wno-unused-private-field"
31-
32-
#TODO: Remove the following defines once asio headers are no longer included in source files
33-
<target-os>windows:<define>_WIN32_WINNT=0x0601
34-
<target-os>windows,<toolset>gcc:<library>ws2_32
35-
<target-os>windows,<toolset>gcc:<library>mswsock
36-
<target-os>windows,<toolset>gcc-cygwin:<define>__USE_W32_SOCKETS
37-
<toolset>msvc:<define>_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING
38-
<toolset>msvc:<define>_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING
39-
<toolset>msvc:<define>_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING
4031
: source-location $(BEAST2_ROOT)
4132
;
4233

@@ -47,10 +38,12 @@ explicit beast2_sources ;
4738
lib boost_beast2
4839
: beast2_sources
4940
: requirements
41+
<library>/boost//corosio
5042
<library>/boost//http
5143
<include>../
5244
<define>BOOST_BEAST2_SOURCE
5345
: usage-requirements
46+
<library>/boost//corosio
5447
<library>/boost//http
5548
;
5649

example/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
# Official repository: https://github.com/cppalliance/beast2
99
#
1010

11-
add_subdirectory(client)
11+
# add_subdirectory(client) # disabled for now
1212
add_subdirectory(server)

example/server/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "" FILES ${PFILES})
1515

1616
add_executable(beast2_server_example ${PFILES})
1717

18-
target_compile_definitions(beast2_server_example
19-
PRIVATE BOOST_ASIO_NO_DEPRECATED)
20-
2118
set_property(TARGET beast2_server_example
2219
PROPERTY FOLDER "examples")
2320

example/server/main.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
// Official repository: https://github.com/cppalliance/beast2
88
//
99

10-
#include "serve_detached.hpp"
1110
#include "serve_log_admin.hpp"
12-
#include <boost/beast2/asio_io_context.hpp>
1311
#include <boost/beast2/server/http_server.hpp>
1412
#include <boost/beast2/server/router.hpp>
1513
#include <boost/beast2/server/serve_static.hpp>
@@ -203,7 +201,7 @@ int server_main( int argc, char* argv[] )
203201
srv.wwwroot.use("/", serve_static( argv[3] ));
204202

205203
app.start();
206-
srv.attach();
204+
srv.run();
207205
}
208206
catch( std::exception const& e )
209207
{

example/server/serve_detached.hpp

Lines changed: 0 additions & 67 deletions
This file was deleted.

include/boost/beast2.hpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,29 @@
1010
#ifndef BOOST_BEAST2_HPP
1111
#define BOOST_BEAST2_HPP
1212

13+
// Server components
1314
#include <boost/beast2/server/any_lambda.hpp>
14-
#include <boost/beast2/server/call_mf.hpp>
1515
#include <boost/beast2/server/fixed_array.hpp>
1616
#include <boost/beast2/server/http_server.hpp>
1717
#include <boost/beast2/server/http_stream.hpp>
18-
#include <boost/beast2/server/plain_worker.hpp>
19-
#include <boost/beast2/server/route_handler_asio.hpp>
18+
#include <boost/beast2/server/route_handler_corosio.hpp>
2019
#include <boost/beast2/server/router.hpp>
21-
#include <boost/beast2/server/router_asio.hpp>
20+
#include <boost/beast2/server/router_corosio.hpp>
2221
#include <boost/beast2/server/serve_redirect.hpp>
2322
#include <boost/beast2/server/serve_static.hpp>
2423
#include <boost/beast2/server/workers.hpp>
24+
25+
// Test utilities
2526
#include <boost/beast2/test/error.hpp>
2627
#include <boost/beast2/test/fail_count.hpp>
27-
#include <boost/beast2/test/stream.hpp>
28-
#include <boost/beast2/test/tcp.hpp>
29-
#include <boost/beast2/asio_io_context.hpp>
30-
#include <boost/beast2/body_read_stream.hpp>
28+
29+
// Core utilities
3130
#include <boost/beast2/buffer.hpp>
3231
#include <boost/beast2/client.hpp>
3332
#include <boost/beast2/endpoint.hpp>
3433
#include <boost/beast2/error.hpp>
35-
#include <boost/beast2/wrap_executor.hpp>
3634
#include <boost/beast2/format.hpp>
3735
#include <boost/beast2/log_service.hpp>
3836
#include <boost/beast2/logger.hpp>
39-
#include <boost/beast2/body_read_stream.hpp>
40-
#include <boost/beast2/read.hpp>
41-
#include <boost/beast2/write.hpp>
4237

4338
#endif

include/boost/beast2/asio_io_context.hpp

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)