diff --git a/CMakeLists.txt b/CMakeLists.txt index eeb8197b..80d322e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ target_link_libraries(aedis Boost::asio Boost::assert Boost::config + Boost::container Boost::core Boost::mp11 Boost::optional @@ -42,7 +43,7 @@ write_basic_package_version_file( COMPATIBILITY AnyNewerVersion ) -find_package(Boost 1.79 REQUIRED) +find_package(Boost 1.79 REQUIRED container) include_directories(${Boost_INCLUDE_DIRS}) find_package(OpenSSL REQUIRED) @@ -77,6 +78,8 @@ add_executable(test_conn_cancel_run tests/conn_cancel_run.cpp) add_executable(test_conn_cancel_exec tests/conn_cancel_exec.cpp) add_executable(test_conn_echo_stress tests/conn_echo_stress.cpp) + + target_compile_features(chat_room PUBLIC cxx_std_20) target_compile_features(containers PUBLIC cxx_std_20) target_compile_features(echo_server PUBLIC cxx_std_20) @@ -100,8 +103,26 @@ target_compile_features(test_conn_cancel_run PUBLIC cxx_std_20) target_compile_features(test_conn_cancel_exec PUBLIC cxx_std_20) target_compile_features(test_conn_echo_stress PUBLIC cxx_std_20) -target_link_libraries(intro_tls OpenSSL::Crypto OpenSSL::SSL) -target_link_libraries(test_conn_tls OpenSSL::Crypto OpenSSL::SSL) +target_link_libraries(intro Boost::container) +target_link_libraries(intro_tls OpenSSL::Crypto OpenSSL::SSL Boost::container) +target_link_libraries(chat_room PUBLIC Boost::container) +target_link_libraries(containers PUBLIC Boost::container) +target_link_libraries(echo_server PUBLIC Boost::container) +target_link_libraries(low_level_sync PUBLIC Boost::container) +target_link_libraries(serialization PUBLIC Boost::container) +target_link_libraries(subscriber PUBLIC Boost::container) +target_link_libraries(subscriber_sentinel PUBLIC Boost::container) +target_link_libraries(test_conn_cancel_exec PUBLIC Boost::container) +target_link_libraries(test_conn_cancel_run PUBLIC Boost::container) +target_link_libraries(test_conn_connect PUBLIC Boost::container) +target_link_libraries(test_conn_push PUBLIC Boost::container) +target_link_libraries(test_conn_quit PUBLIC Boost::container) +target_link_libraries(test_conn_quit_coalesce PUBLIC Boost::container) +target_link_libraries(test_conn_reconnect PUBLIC Boost::container) +target_link_libraries(test_conn_reconnect PUBLIC Boost::container) +target_link_libraries(test_conn_request PUBLIC Boost::container) +target_link_libraries(test_conn_tls OpenSSL::Crypto OpenSSL::SSL Boost::container) + # Tests #======================================================================= diff --git a/examples/serialization.cpp b/examples/serialization.cpp index d00eef46..661e07e0 100644 --- a/examples/serialization.cpp +++ b/examples/serialization.cpp @@ -57,7 +57,7 @@ user tag_invoke(value_to_tag, value const& jv) } // Serializes -void to_bulk(std::string& to, user const& u) +void to_bulk(boost::container::pmr::string& to, user const& u) { aedis::resp3::to_bulk(to, serialize(value_from(u))); } diff --git a/include/aedis/resp3/request.hpp b/include/aedis/resp3/request.hpp index 25c3a26a..689fd665 100644 --- a/include/aedis/resp3/request.hpp +++ b/include/aedis/resp3/request.hpp @@ -11,6 +11,8 @@ #include #include +#include +#include #include #include @@ -205,11 +207,18 @@ public: * * @param cfg Configuration options. */ - explicit request(config cfg = config{false, true, false, true}) - : cfg_{cfg} + explicit request(boost::container::pmr::memory_resource * resource) + : payload_(resource), cfg_{false, true, false, true} {} - //// Returns the number of commands contained in this request. + explicit request(config cfg = config{false, true, false, true}, + boost::container::pmr::memory_resource * resource = + boost::container::pmr::get_default_resource()) + : payload_(resource), cfg_{cfg} + {} + + + //// Returns the number of commands contained in this request. [[nodiscard]] auto size() const noexcept -> std::size_t { return commands_;}; // Returns the request payload. @@ -380,7 +389,7 @@ public: [[nodiscard]] auto get_config() noexcept -> auto& {return cfg_; } private: - std::string payload_; + boost::container::pmr::string payload_; std::size_t commands_ = 0; config cfg_; }; diff --git a/tests/conn_request.cpp b/tests/conn_request.cpp index 19f9cb6f..cd4e0e1b 100644 --- a/tests/conn_request.cpp +++ b/tests/conn_request.cpp @@ -8,6 +8,8 @@ #include #include +#include + #define BOOST_TEST_MODULE low level #include @@ -50,7 +52,10 @@ BOOST_AUTO_TEST_CASE(wrong_response_data_type) BOOST_AUTO_TEST_CASE(cancel_request_if_not_connected) { std::cout << boost::unit_test::framework::current_test_case().p_name << std::endl; - request req; + namespace pmr = boost::container::pmr; + char buf[4096]; + pmr::monotonic_buffer_resource resource{buf, 4096}; + request req{&resource}; req.get_config().cancel_if_not_connected = true; req.push("PING");