Skip to content

Commit 30a6e34

Browse files
authored
Merge pull request #97 from boostorg/85-added-example-cpp20_streams-which-reproduces-an-assertion
85 added example cpp20 streams which reproduces an assertion
2 parents 2d53bb7 + 1f9b3e8 commit 30a6e34

15 files changed

+122
-14
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ if (MSVC)
9292
target_compile_definitions(cpp20_intro PRIVATE _WIN32_WINNT=0x0601)
9393
endif()
9494

95+
add_executable(cpp20_streams examples/cpp20_streams.cpp)
96+
target_link_libraries(cpp20_streams common)
97+
target_compile_features(cpp20_streams PUBLIC cxx_std_20)
98+
if (MSVC)
99+
target_compile_options(cpp20_streams PRIVATE /bigobj)
100+
target_compile_definitions(cpp20_streams PRIVATE _WIN32_WINNT=0x0601)
101+
endif()
102+
95103
add_executable(cpp17_intro examples/cpp17_intro.cpp)
96104
target_compile_features(cpp17_intro PUBLIC cxx_std_17)
97105
add_test(cpp17_intro cpp17_intro)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ Acknowledgement to people that helped shape Boost.Redis
678678
* Mohammad Nejati ([ashtum](https://github.com/ashtum)): For pointing out scenarios where calls to `async_exec` should fail when the connection is lost.
679679
* Klemens Morgenstern ([klemens-morgenstern](https://github.com/klemens-morgenstern)): For useful discussion about timeouts, cancellation, synchronous interfaces and general help with Asio.
680680
* Vinnie Falco ([vinniefalco](https://github.com/vinniefalco)): For general suggestions about how to improve the code and the documentation.
681+
* Bram Veldhoen ([bveldhoen](https://github.com/bveldhoen)): For contributing a Redis streams example.
681682

682683
Also many thanks to all individuals that participated in the Boost
683684
review
@@ -702,6 +703,8 @@ https://lists.boost.org/Archives/boost/2023/01/253944.php.
702703

703704
### master (incorporates changes to conform the boost review and more)
704705

706+
* Adds Redis stream example.
707+
705708
* Renames the project to Boost.Redis and moves the code into namespace
706709
`boost::redis`.
707710

examples/cpp20_chat_room.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ auto publisher(std::shared_ptr<stream_descriptor> in, std::shared_ptr<connection
7272
}
7373

7474
// Called from the main function (see main.cpp)
75-
auto co_main(config const& cfg) -> net::awaitable<void>
75+
auto co_main(config cfg) -> net::awaitable<void>
7676
{
7777
auto ex = co_await net::this_coro::executor;
7878
auto conn = std::make_shared<connection>(ex);

examples/cpp20_containers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ auto transaction(std::shared_ptr<connection> conn) -> net::awaitable<void>
8989
}
9090

9191
// Called from the main function (see main.cpp)
92-
net::awaitable<void> co_main(config const& cfg)
92+
net::awaitable<void> co_main(config cfg)
9393
{
9494
auto conn = std::make_shared<connection>(co_await net::this_coro::executor);
9595
conn->async_run(cfg, {}, net::consign(net::detached, conn));

examples/cpp20_echo_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ auto listener(std::shared_ptr<connection> conn) -> net::awaitable<void>
5555
}
5656

5757
// Called from the main function (see main.cpp)
58-
auto co_main(config const& cfg) -> net::awaitable<void>
58+
auto co_main(config cfg) -> net::awaitable<void>
5959
{
6060
auto ex = co_await net::this_coro::executor;
6161
auto conn = std::make_shared<connection>(ex);

examples/cpp20_intro.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using boost::redis::logger;
2121
using connection = net::deferred_t::as_default_on_t<boost::redis::connection>;
2222

2323
// Called from the main function (see main.cpp)
24-
auto co_main(config const& cfg) -> net::awaitable<void>
24+
auto co_main(config cfg) -> net::awaitable<void>
2525
{
2626
auto conn = std::make_shared<connection>(co_await net::this_coro::executor);
2727
conn->async_run(cfg, {}, net::consign(net::detached, conn));

examples/cpp20_intro_tls.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ auto verify_certificate(bool, net::ssl::verify_context&) -> bool
2626
return true;
2727
}
2828

29-
auto co_main(config const&) -> net::awaitable<void>
29+
auto co_main(config cfg) -> net::awaitable<void>
3030
{
31-
config cfg;
3231
cfg.username = "aedis";
3332
cfg.password = "aedis";
3433
cfg.addr.host = "db.occase.de";

examples/cpp20_json.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void boost_redis_to_bulk(std::string& to, user const& u)
4545
void boost_redis_from_bulk(user& u, std::string_view sv, boost::system::error_code& ec)
4646
{ boost::redis::json::from_bulk(u, sv, ec); }
4747

48-
net::awaitable<void> co_main(config const& cfg)
48+
auto co_main(config cfg) -> net::awaitable<void>
4949
{
5050
auto ex = co_await net::this_coro::executor;
5151
auto conn = std::make_shared<connection>(ex);

examples/cpp20_protobuf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void boost_redis_from_bulk(person& u, std::string_view sv, boost::system::error_
4444
using tutorial::boost_redis_to_bulk;
4545
using tutorial::boost_redis_from_bulk;
4646

47-
net::awaitable<void> co_main(config const& cfg)
47+
net::awaitable<void> co_main(config cfg)
4848
{
4949
auto ex = co_await net::this_coro::executor;
5050
auto conn = std::make_shared<connection>(ex);

examples/cpp20_resolve_with_sentinel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ auto resolve_master_address(std::vector<address> const& addresses) -> net::await
5555
co_return address{};
5656
}
5757

58-
auto co_main(config const& cfg) -> net::awaitable<void>
58+
auto co_main(config cfg) -> net::awaitable<void>
5959
{
6060
// A list of sentinel addresses from which only one is responsive.
6161
// This simulates sentinels that are down.

0 commit comments

Comments
 (0)