Skip to content

Commit f4f14de

Browse files
committed
[hosted] Fix deprecated use of boost::asio::io_service
1 parent e21f6e6 commit f4f14de

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

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)