Skip to content

Commit 51a6d0f

Browse files
committed
[hosted] Fix deprecated use of boost::asio::io_service
1 parent 6915cc0 commit 51a6d0f

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

src/modm/platform/uart/hosted/module.lb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ def build(env):
3434
# FIXME: boost/type_traits/detail/config.hpp:85:69: warning: "__clang_major___WORKAROUND_GUARD" is not defined, evaluates to 0
3535
env.collect(":build:cppdefines.release", "__clang_major___WORKAROUND_GUARD=4")
3636

37-
env.collect(":build:library", "boost_system")
37+
env.collect(":build:library", "boost_system", "boost_thread")
3838
if env[":target"].identifier.family == "linux":
39-
env.collect(":build:library", "boost_thread", "pthread")
40-
else:
41-
env.collect(":build:library", "boost_thread-mt")
39+
env.collect(":build:library", "pthread")
4240

4341
env.outbasepath = "modm/src/modm/platform/uart"
4442
env.copy(".")

src/modm/platform/uart/hosted/serial_port.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
modm::platform::SerialPort::SerialPort():
1818
shutdown(true),
19-
port(io_service)
19+
port(io_context)
2020
{
2121
}
2222

@@ -28,7 +28,7 @@ modm::platform::SerialPort::~SerialPort()
2828
void
2929
modm::platform::SerialPort::write(char c)
3030
{
31-
this->io_service.post(boost::bind(&modm::platform::SerialPort::doWrite, this, c));
31+
boost::asio::post(this->io_context, boost::bind(&modm::platform::SerialPort::doWrite, this, c));
3232
}
3333

3434

@@ -84,9 +84,9 @@ modm::platform::SerialPort::open(std::string deviceName, unsigned int baudRate)
8484
this->port.set_option(boost::asio::serial_port_base::character_size(8));
8585
this->port.set_option(boost::asio::serial_port_base::stop_bits(boost::asio::serial_port_base::stop_bits::one));
8686

87-
this->io_service.post(boost::bind(&SerialPort::readStart, this));
87+
boost::asio::post(this->io_context, boost::bind(&SerialPort::readStart, this));
8888

89-
this->thread = new boost::thread(boost::bind(&boost::asio::io_service::run, &this->io_service));
89+
this->thread = new boost::thread(boost::bind(&boost::asio::io_context::run, &this->io_context));
9090
}
9191
else {
9292
std::cerr << "Port already open!" << std::endl;
@@ -108,14 +108,14 @@ modm::platform::SerialPort::close()
108108
if (!this->isOpen())
109109
return;
110110

111-
this->io_service.post(boost::bind(
111+
boost::asio::post(this->io_context, boost::bind(
112112
&modm::platform::SerialPort::doClose,
113113
this,
114114
boost::system::error_code()));
115115

116116
this->thread->join();
117117
delete this->thread;
118-
this->io_service.reset();
118+
this->io_context.restart();
119119
}
120120

121121
void
@@ -124,14 +124,14 @@ modm::platform::SerialPort::kill()
124124
if (!this->isOpen())
125125
return;
126126

127-
this->io_service.post(boost::bind(
127+
boost::asio::post(this->io_context, boost::bind(
128128
&modm::platform::SerialPort::doAbort,
129129
this,
130130
boost::system::error_code()));
131131
this->shutdown = true;
132132
this->thread->join();
133133
delete this->thread;
134-
this->io_service.reset();
134+
this->io_context.restart();
135135
}
136136

137137
void

src/modm/platform/uart/hosted/serial_port.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ namespace modm
8787
std::queue<char> writeBuffer;
8888
std::queue<char> readBuffer;
8989

90-
boost::asio::io_service io_service;
90+
boost::asio::io_context io_context;
9191
boost::asio::serial_port port;
9292
boost::thread* thread;
9393

0 commit comments

Comments
 (0)