xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
xrpld
app
main
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
10
BasicApp::BasicApp
(
std::size_t
numberOfThreads)
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]() {
18
beast::setCurrentThreadName
(
"io svc #"
+
std::to_string
(i));
19
this->
ioContext_
.run();
20
});
21
}
22
}
23
24
BasicApp::~BasicApp
()
25
{
26
work_
.reset();
27
28
for
(
auto
& t :
threads_
)
29
t.join();
30
}
BasicApp::threads_
std::vector< std::thread > threads_
Definition
BasicApp.h:15
BasicApp::~BasicApp
~BasicApp()
Definition
BasicApp.cpp:24
BasicApp::BasicApp
BasicApp(std::size_t numberOfThreads)
Definition
BasicApp.cpp:10
BasicApp::work_
std::optional< boost::asio::executor_work_guard< boost::asio::io_context::executor_type > > work_
Definition
BasicApp.h:14
BasicApp::ioContext_
boost::asio::io_context ioContext_
Definition
BasicApp.h:16
cstddef
beast::setCurrentThreadName
void setCurrentThreadName(std::string_view newThreadName)
Changes the name of the caller thread.
Definition
CurrentThreadName.cpp:115
std::size_t
string
std::to_string
T to_string(T... args)
Generated by
1.17.0