2
0
mirror of https://github.com/boostorg/redis.git synced 2026-01-19 04:42:09 +00:00

Refactoring.

This commit is contained in:
Marcelo Zimbres
2022-06-12 08:44:37 +02:00
parent 77fe3a0f5f
commit ce9cb04168
5 changed files with 290 additions and 214 deletions

View File

@@ -37,18 +37,25 @@ example(boost::asio::ip::tcp::endpoint ep, std::string msg, int n)
}
}
int main()
int main(int argc, char* argv[])
{
try {
int sessions = 1;
int msgs = 1;
if (argc == 3) {
sessions = std::stoi(argv[1]);
msgs = std::stoi(argv[2]);
}
net::io_context ioc;
tcp::resolver resv{ioc};
auto const res = resv.resolve("127.0.0.1", "55555");
auto ep = *std::begin(res);
int n = 10000;
for (int i = 0; i < 500; ++i)
net::co_spawn(ioc, example(ep, "Some message\n", n), net::detached);
for (int i = 0; i < sessions; ++i)
net::co_spawn(ioc, example(ep, "Some message\n", msgs), net::detached);
ioc.run();
} catch (std::exception const& e) {