Skip to content

Commit 11eebcf

Browse files
committed
Fixes redis.hpp and slightly improves compilation times.
1 parent c21f70b commit 11eebcf

18 files changed

+423
-474
lines changed

CMakeLists.txt

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
cmake_minimum_required(VERSION 3.14)
22

3+
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time")
4+
35
project(
46
boost_redis
57
VERSION 1.4.1
@@ -65,9 +67,9 @@ foreach(lib IN LISTS libs_cpp20 libs_cpp17 libs_common)
6567
add_library(${lib} STATIC)
6668
endforeach()
6769

68-
target_sources(boost_redis_src PUBLIC examples/boost_redis.cpp)
69-
target_sources(tests_common PUBLIC tests/common.cpp)
70-
target_sources(examples_main PUBLIC examples/main.cpp)
70+
target_sources(boost_redis_src PRIVATE examples/boost_redis.cpp)
71+
target_sources(tests_common PRIVATE tests/common.cpp)
72+
target_sources(examples_main PRIVATE examples/main.cpp)
7173

7274
# Executables
7375
#=======================================================================
@@ -134,16 +136,17 @@ foreach(exe IN LISTS tests_cpp17 tests_cpp20)
134136
target_link_libraries(${exe} PRIVATE tests_common)
135137
endforeach()
136138

137-
foreach(exe IN LISTS tests_cpp17 tests_cpp20 examples_cpp17 examples_cpp20 libs_cpp17 libs_cpp20 benchmakrs)
138-
target_link_libraries(${exe} PRIVATE OpenSSL::Crypto OpenSSL::SSL boost_redis_src)
139-
endforeach()
140-
141-
if (MSVC)
142-
foreach(exe IN LISTS tests_cpp17 tests_cpp20 examples_cpp17 examples_cpp20 libs_cpp17 libs_cpp20 benchmakrs libs_common)
139+
foreach(exe IN LISTS tests_cpp17 tests_cpp20 examples_cpp17 examples_cpp20 libs_cpp17 libs_cpp20 libs_common benchmakrs)
140+
target_link_libraries(${exe} PRIVATE OpenSSL::Crypto OpenSSL::SSL)
141+
if (MSVC)
143142
target_compile_options(${exe} PRIVATE /bigobj)
144143
target_compile_definitions(${exe} PRIVATE _WIN32_WINNT=0x0601)
145-
endforeach()
146-
endif()
144+
endif()
145+
endforeach()
146+
147+
foreach(exe IN LISTS tests_cpp17 tests_cpp20 examples_cpp17 examples_cpp20 libs_cpp17 libs_cpp20 benchmakrs)
148+
target_link_libraries(${exe} PRIVATE boost_redis_src)
149+
endforeach()
147150

148151
foreach(exe IN LISTS tests_cpp20 examples_cpp20 libs_cpp20 benchmarks)
149152
target_compile_features(${exe} PUBLIC cxx_std_20)

examples/boost_redis.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,11 @@
44
* accompanying file LICENSE.txt)
55
*/
66

7+
#include <boost/redis/config.hpp>
8+
#include <boost/redis/connection.hpp>
9+
#include <boost/redis/request.hpp>
10+
#include <boost/asio/detached.hpp>
11+
#include <boost/asio/deferred.hpp>
12+
#include <boost/asio/consign.hpp>
13+
714
#include <boost/redis/src.hpp>

examples/cpp20_containers.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
#if defined(BOOST_ASIO_HAS_CO_AWAIT)
1616

1717
namespace net = boost::asio;
18-
namespace redis = boost::redis;
19-
using redis::request;
20-
using redis::response;
21-
using redis::ignore_t;
22-
using redis::ignore;
23-
using redis::config;
18+
using boost::redis::request;
19+
using boost::redis::response;
20+
using boost::redis::ignore_t;
21+
using boost::redis::ignore;
22+
using boost::redis::config;
2423
using connection = net::deferred_t::as_default_on_t<boost::redis::connection>;
2524

2625
void print(std::map<std::string, std::string> const& cont)

examples/cpp20_json.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <boost/asio/consign.hpp>
1313
#include <string>
1414
#include <iostream>
15+
1516
#if defined(BOOST_ASIO_HAS_CO_AWAIT)
1617

1718
#define BOOST_JSON_NO_LIB
@@ -21,12 +22,12 @@
2122

2223
namespace net = boost::asio;
2324
using namespace boost::describe;
24-
using connection = net::deferred_t::as_default_on_t<boost::redis::connection>;
2525
using boost::redis::request;
2626
using boost::redis::response;
2727
using boost::redis::operation;
2828
using boost::redis::ignore_t;
2929
using boost::redis::config;
30+
using connection = net::deferred_t::as_default_on_t<boost::redis::connection>;
3031

3132
// Struct that will be stored in Redis using json serialization.
3233
struct user {

examples/cpp20_resolve_with_sentinel.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
#if defined(BOOST_ASIO_HAS_CO_AWAIT)
1414

1515
namespace net = boost::asio;
16-
namespace redis = boost::redis;
1716
using endpoints = net::ip::tcp::resolver::results_type;
18-
using redis::request;
19-
using redis::response;
20-
using redis::ignore_t;
21-
using redis::config;
22-
using redis::address;
17+
using boost::redis::request;
18+
using boost::redis::response;
19+
using boost::redis::ignore_t;
20+
using boost::redis::config;
21+
using boost::redis::address;
2322
using connection = boost::asio::use_awaitable_t<>::as_default_on_t<boost::redis::connection>;
2423

2524
auto redir(boost::system::error_code& ec)

examples/cpp20_streams.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ auto co_main(config cfg) -> net::awaitable<void>
8888
net::co_spawn(ex, stream_reader(conn), net::detached);
8989

9090
// Disable health checks.
91-
cfg.health_check_interval = std::chrono::seconds{0};
91+
cfg.health_check_interval = std::chrono::seconds::zero();
9292
conn->async_run(cfg, {}, net::consign(net::detached, conn));
9393

9494
signal_set sig_set(ex, SIGINT, SIGTERM);

examples/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* accompanying file LICENSE.txt)
55
*/
66

7+
#include <boost/redis/connection.hpp>
78
#include <boost/redis/config.hpp>
89
#include <boost/asio/co_spawn.hpp>
910
#include <boost/asio/use_awaitable.hpp>
@@ -12,6 +13,7 @@
1213

1314
namespace net = boost::asio;
1415
using boost::redis::config;
16+
using boost::redis::logger;
1517

1618
#if defined(BOOST_ASIO_HAS_CO_AWAIT)
1719

include/boost/redis.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#include <boost/redis/connection.hpp>
1313
#include <boost/redis/request.hpp>
1414
#include <boost/redis/response.hpp>
15-
#include <boost/redis/run.hpp>
16-
#include <boost/redis/address.hpp>
1715
#include <boost/redis/ignore.hpp>
1816
#include <boost/redis/logger.hpp>
1917

0 commit comments

Comments
 (0)