xrpld
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
7#include <cstddef>
8#include <string>
9
11{
12 work_.emplace(boost::asio::make_work_guard(ioContext_));
13 threads_.reserve(numberOfThreads);
14
15 for (std::size_t i = 0; i < numberOfThreads; ++i)
16 {
17 threads_.emplace_back([this, i]() {
19 this->ioContext_.run();
20 });
21 }
22}
23
25{
26 work_.reset();
27
28 for (auto& t : threads_)
29 t.join();
30}
std::vector< std::thread > threads_
Definition BasicApp.h:14
BasicApp(std::size_t numberOfThreads)
Definition BasicApp.cpp:10
std::optional< boost::asio::executor_work_guard< boost::asio::io_context::executor_type > > work_
Definition BasicApp.h:13
boost::asio::io_context ioContext_
Definition BasicApp.h:15
void setCurrentThreadName(std::string_view newThreadName)
Changes the name of the caller thread.
T to_string(T... args)