Skip to content

Commit e478ca7

Browse files
authored
Don't use deprecated boost functionality, be compatible to boost 1.87 (#2535)
1 parent 1c2a0d3 commit e478ca7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Framework/src/RepositoryBenchmark.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class RepositoryBenchmark : public fair::mq::Device
6464

6565
// variables for the timer
6666
boost::asio::deadline_timer* mTimer; /// the asynchronous timer to send monitoring data
67-
boost::asio::io_service io;
67+
boost::asio::io_context io;
6868
std::thread* th;
6969
};
7070

Framework/src/ServiceDiscovery.cxx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <boost/algorithm/string/split.hpp>
2525
#include <boost/algorithm/string.hpp>
2626
#include <boost/asio/ip/tcp.hpp>
27-
#include <boost/asio/io_service.hpp>
27+
#include <boost/asio/io_context.hpp>
2828
#include <iostream>
2929
#include <InfoLogger/InfoLoggerMacros.hxx>
3030
#include <boost/system/error_code.hpp>
@@ -136,7 +136,7 @@ void ServiceDiscovery::runHealthServer()
136136
threadInfoLogger.setContext(context);
137137

138138
// Find a free port and create the endpoint and the acceptor
139-
boost::asio::io_service io_service;
139+
boost::asio::io_context io_context;
140140
tcp::acceptor* acceptor = nullptr;
141141
size_t port = 0;
142142
std::random_device rd; // obtain a random number from hardware
@@ -153,7 +153,7 @@ void ServiceDiscovery::runHealthServer()
153153
cycle++;
154154

155155
tcp::endpoint endpoint(tcp::v4(), port);
156-
acceptor = new tcp::acceptor(io_service, endpoint);
156+
acceptor = new tcp::acceptor(io_context, endpoint);
157157
} catch (boost::system::system_error& e) {
158158
ILOG(Debug, Trace) << "ServiceDiscovery::runHealthServer - cound not bind to " << port << ENDM;
159159
continue; // try the next one
@@ -177,16 +177,16 @@ void ServiceDiscovery::runHealthServer()
177177

178178
// run the thread
179179
try {
180-
boost::asio::deadline_timer timer(io_service);
180+
boost::asio::deadline_timer timer(io_context);
181181
while (mThreadRunning) {
182-
io_service.reset();
182+
io_context.restart();
183183
timer.expires_from_now(boost::posix_time::seconds(1));
184184
acceptor->async_accept([this](boost::system::error_code ec, tcp::socket socket) {
185185
});
186186
timer.async_wait([&](boost::system::error_code ec) {
187-
io_service.stop();
187+
io_context.stop();
188188
});
189-
io_service.run();
189+
io_context.run();
190190
}
191191
} catch (std::exception& e) {
192192
mThreadRunning = false;

0 commit comments

Comments
 (0)