Skip to content

Commit 4ef84b3

Browse files
committed
Boost: Migrate deprecated components to 1.87
1 parent 328a9ce commit 4ef84b3

File tree

14 files changed

+48
-46
lines changed

14 files changed

+48
-46
lines changed

src/game/Server/WorldSocket.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ std::deque<uint32> WorldSocket::GetIncOpcodeHistory()
9292
return m_opcodeHistoryInc;
9393
}
9494

95-
WorldSocket::WorldSocket(boost::asio::io_service& service) : AsyncSocket(service), m_lastPingTime(std::chrono::system_clock::time_point::min()), m_overSpeedPings(0),
95+
WorldSocket::WorldSocket(boost::asio::io_context& context) : AsyncSocket(context), m_lastPingTime(std::chrono::system_clock::time_point::min()), m_overSpeedPings(0),
9696
m_session(nullptr), m_seed(urand()), m_loggingPackets(false)
9797
{
9898
}

src/game/Server/WorldSocket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class WorldSocket : public MaNGOS::AsyncSocket<WorldSocket>
126126
bool m_loggingPackets;
127127

128128
public:
129-
WorldSocket(boost::asio::io_service& service);
129+
WorldSocket(boost::asio::io_context& context);
130130

131131
// send a packet \o/
132132
void SendPacket(const WorldPacket& pct, bool immediate = false);

src/mangosd/Master.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,11 @@ int Master::Run()
227227
}
228228
std::string bindIp = sConfig.GetStringDefault("BindIP", "0.0.0.0");
229229
int32 port = int32(sWorld.getConfig(CONFIG_UINT32_PORT_WORLD));
230-
MaNGOS::AsyncListener<WorldSocket> listener(m_service, bindIp, port);
230+
MaNGOS::AsyncListener<WorldSocket> listener(m_context, bindIp, port);
231231

232232
std::vector<std::thread> threads;
233233
for (int32 i = 0; i < networkThreadCount; ++i)
234-
threads.emplace_back([&]() { m_service.run(); });
234+
threads.emplace_back([&]() { m_context.run(); });
235235

236236
std::unique_ptr<MaNGOS::AsyncListener<RASocket>> raListener;
237237
std::string raBindIp = sConfig.GetStringDefault("Ra.IP", "0.0.0.0");
@@ -240,8 +240,8 @@ int Master::Run()
240240
bool raEnable = sConfig.GetBoolDefault("Ra.Enable", false);
241241
if (raEnable)
242242
{
243-
raListener.reset(new MaNGOS::AsyncListener<RASocket>(m_raService, raBindIp, raPort));
244-
m_raThread = std::thread([this]() { m_raService.run(); });
243+
raListener.reset(new MaNGOS::AsyncListener<RASocket>(m_raContext, raBindIp, raPort));
244+
m_raThread = std::thread([this]() { m_raContext.run(); });
245245
}
246246

247247
std::unique_ptr<SOAPThread> soapThread;
@@ -254,11 +254,11 @@ int Master::Run()
254254

255255
world_thread.wait();
256256

257-
m_service.stop();
257+
m_context.stop();
258258

259259
if (raEnable)
260260
{
261-
m_raService.stop();
261+
m_raContext.stop();
262262
m_raThread.join();
263263
}
264264

src/mangosd/Master.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class Master
4444

4545
void clearOnlineAccounts();
4646

47-
boost::asio::io_service m_service;
48-
boost::asio::io_service m_raService;
47+
boost::asio::io_context m_context;
48+
boost::asio::io_context m_raContext;
4949
};
5050

5151
#define sMaster MaNGOS::Singleton<Master>::Instance()

src/mangosd/RASocket.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
#include <string>
3838

3939
/// RASocket constructor
40-
RASocket::RASocket(boost::asio::io_service& service) :
41-
MaNGOS::AsyncSocket<RASocket>(service), m_secure(sConfig.GetBoolDefault("RA.Secure", true)),
40+
RASocket::RASocket(boost::asio::io_context& context) :
41+
MaNGOS::AsyncSocket<RASocket>(context), m_secure(sConfig.GetBoolDefault("RA.Secure", true)),
4242
m_authLevel(AuthLevel::None), m_accountLevel(AccountTypes::SEC_PLAYER), m_accountId(0)
4343
{
4444
if (sConfig.IsSet("RA.Stricted"))

src/mangosd/RASocket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class RASocket : public MaNGOS::AsyncSocket<RASocket>
5656
void Send(const std::string& message);
5757

5858
public:
59-
RASocket(boost::asio::io_service& service);
59+
RASocket(boost::asio::io_context& context);
6060
virtual ~RASocket();
6161

6262
bool OnOpen() override;

src/realmd/AuthSocket.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ const char logonProofVersionInvalid[2] = { CMD_AUTH_LOGON_PROOF, AUTH_LOGON_FAIL
191191
const char logonProofUnknownAccountPinInvalid[4] = { CMD_AUTH_LOGON_PROOF, AUTH_LOGON_FAILED_UNKNOWN_ACCOUNT, 3, 0 };
192192

193193
/// Constructor - set the N and g values for SRP6
194-
AuthSocket::AuthSocket(boost::asio::io_service& service)
195-
: AsyncSocket<AuthSocket>(service), _status(STATUS_CHALLENGE), _build(0), _accountSecurityLevel(SEC_PLAYER), m_timeoutTimer(service)
194+
AuthSocket::AuthSocket(boost::asio::io_context& context)
195+
: AsyncSocket<AuthSocket>(context), _status(STATUS_CHALLENGE), _build(0), _accountSecurityLevel(SEC_PLAYER), m_timeoutTimer(context)
196196
{
197197
}
198198

src/realmd/AuthSocket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class AuthSocket : public MaNGOS::AsyncSocket<AuthSocket>
4545
public:
4646
const static int s_BYTE_SIZE = 32;
4747

48-
AuthSocket(boost::asio::io_service& service);
48+
AuthSocket(boost::asio::io_context& context);
4949

5050
bool OnOpen() override;
5151

src/realmd/Main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ bool restart = false;
7373

7474
DatabaseType LoginDatabase; // Accessor to the realm server database
7575

76-
boost::asio::io_service service;
76+
boost::asio::io_context context;
7777

7878
// Launch the realm server
7979
int main(int argc, char* argv[])
@@ -239,14 +239,14 @@ int main(int argc, char* argv[])
239239
LoginDatabase.CommitTransaction();
240240

241241
uint32 networkThreadCount = sConfig.GetIntDefault("ListenerThreads", 1);
242-
MaNGOS::AsyncListener<AuthSocket> listener(service,
242+
MaNGOS::AsyncListener<AuthSocket> listener(context,
243243
sConfig.GetStringDefault("BindIP", "0.0.0.0"),
244244
sConfig.GetIntDefault("RealmServerPort", DEFAULT_REALMSERVER_PORT)
245245
);
246246

247247
std::vector<std::thread> threads;
248248
for (uint32 i = 0; i < networkThreadCount; ++i)
249-
threads.emplace_back([&]() { service.run(); });
249+
threads.emplace_back([&]() { context.run(); });
250250

251251
// Catch termination signals
252252
HookSignals();
@@ -320,7 +320,7 @@ int main(int argc, char* argv[])
320320
#endif
321321
}
322322

323-
service.stop();
323+
context.stop();
324324

325325
for (uint32 i = 0; i < networkThreadCount; ++i)
326326
threads[i].join();

src/shared/Metric/Metric.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,15 @@ metric::metric::~metric()
8484
if (!m_enabled)
8585
return;
8686

87-
m_writeService.post([&] {
87+
boost::asio::post(m_writeContext, [&] {
8888
m_sendTimer->cancel();
8989
});
9090

91-
m_queueServiceWork.reset();
92-
m_writeServiceWork.reset();
91+
m_queueContextWork.get()->reset();
92+
m_writeContextWork.get()->reset();
93+
94+
m_queueContextWork.reset();
95+
m_writeContextWork.reset();
9396

9497
m_queueServiceThread.join();
9598
m_writeServiceThread.join();
@@ -108,17 +111,17 @@ void metric::metric::initialize()
108111
sConfig.GetStringDefault("Metric.Password", "")
109112
};
110113

111-
m_sendTimer.reset(new boost::asio::deadline_timer(m_writeService));
112-
m_queueServiceWork.reset(new boost::asio::io_service::work(m_queueService));
113-
m_writeServiceWork.reset(new boost::asio::io_service::work(m_writeService));
114+
m_sendTimer.reset(new boost::asio::deadline_timer(m_writeContext));
115+
m_queueContextWork = std::make_unique<boost::asio::executor_work_guard<boost::asio::io_context::executor_type>>(boost::asio::make_work_guard(m_queueContext));
116+
m_writeContextWork = std::make_unique<boost::asio::executor_work_guard<boost::asio::io_context::executor_type>>(boost::asio::make_work_guard(m_writeContext));
114117

115118
// Start up service thread that will process all queued tasks
116119
m_queueServiceThread = std::thread([&] {
117-
m_queueService.run();
120+
m_queueContext.run();
118121
});
119122

120123
m_writeServiceThread = std::thread([&] {
121-
m_writeService.run();
124+
m_writeContext.run();
122125
});
123126

124127
schedule_timer();
@@ -137,8 +140,7 @@ void metric::metric::reload_config()
137140
initialize();
138141
return;
139142
}
140-
141-
m_writeService.post([&]
143+
boost::asio::post(m_writeContext, [&]
142144
{
143145
m_connectionInfo = {
144146
sConfig.GetStringDefault("Metric.Address", "127.0.0.1"),
@@ -160,7 +162,7 @@ void metric::metric::report(std::string measurement, std::map<std::string, boost
160162
if (!m_enabled)
161163
return;
162164

163-
m_queueService.post([&, measurement, fields, tags]
165+
boost::asio::post(m_queueContext, [&, measurement, fields, tags]
164166
{
165167
std::lock_guard<std::mutex> guard(m_queueWriteLock);
166168
m_measurementQueue.push_back(std::make_unique<Measurement>(measurement, tags, fields));
@@ -209,9 +211,9 @@ void metric::metric::send()
209211
boost::system::error_code error;
210212

211213
// Hostname resolution
212-
tcp::resolver resolver(m_writeService);
213-
tcp::resolver::query query(m_connectionInfo.hostname, std::to_string(m_connectionInfo.port));
214-
tcp::resolver::iterator endpoint_iterator = resolver.resolve(query, error);
214+
tcp::resolver resolver(m_writeContext);
215+
auto endpoints = resolver.resolve(m_connectionInfo.hostname, std::to_string(m_connectionInfo.port), error);
216+
auto endpoint_iterator = endpoints.begin();
215217

216218
if (error)
217219
{
@@ -221,9 +223,9 @@ void metric::metric::send()
221223

222224
error = boost::asio::error::host_not_found;
223225

224-
tcp::resolver::iterator end;
226+
auto end = endpoints.end();
225227

226-
tcp::socket socket(m_writeService);
228+
tcp::socket socket(m_writeContext);
227229
while (error && endpoint_iterator != end)
228230
{
229231
socket.close();

0 commit comments

Comments
 (0)