rippled
Loading...
Searching...
No Matches
BasicApp.cpp
1#include <xrpld/app/main/BasicApp.h>
2
3#include <xrpl/beast/core/CurrentThreadName.h>
4
5#include <boost/asio/executor_work_guard.hpp>
6
8{
9 work_.emplace(boost::asio::make_work_guard(io_context_));
10 threads_.reserve(numberOfThreads);
11
12 while (numberOfThreads--)
13 {
14 threads_.emplace_back([this, numberOfThreads]() {
15 beast::setCurrentThreadName("io svc #" + std::to_string(numberOfThreads));
16 this->io_context_.run();
17 });
18 }
19}
20
22{
23 work_.reset();
24
25 for (auto& t : threads_)
26 t.join();
27}
boost::asio::io_context io_context_
Definition BasicApp.h:16
std::vector< std::thread > threads_
Definition BasicApp.h:15
BasicApp(std::size_t numberOfThreads)
Definition BasicApp.cpp:7
std::optional< boost::asio::executor_work_guard< boost::asio::io_context::executor_type > > work_
Definition BasicApp.h:14
T emplace_back(T... args)
T emplace(T... args)
void setCurrentThreadName(std::string_view newThreadName)
Changes the name of the caller thread.
T reserve(T... args)
T reset(T... args)
T to_string(T... args)