Skip to content

Commit

Permalink
Update boost::asio usage to conform to newer standards: (#144)
Browse files Browse the repository at this point in the history
* Convert boost::asio::io_service to boost::asio::io_context
  * Convert strand.wrap(...) to boost::asio::bind_executor(strand, ...)
  * Convert strand.dispatch(...) to boost::asio::dispatch(strand, ...)
  * Convert io_context.reset() to io_context.restart()
  * Convert null_buffers() usage to socket.async_wait(...)
  * Drop usage of GET_IO_SERVICE macro from monero
  * Refactor REST server to manage resources better
  • Loading branch information
vtnerd authored Nov 20, 2024
1 parent ef78f19 commit 18b5743
Show file tree
Hide file tree
Showing 17 changed files with 259 additions and 197 deletions.
2 changes: 1 addition & 1 deletion src/client_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ namespace
boost::this_thread::sleep_for(boost::chrono::seconds{1});

self.stop_ = false;
self.io_.reset();
self.io_.restart();
if (self.has_shutdown())
return;

Expand Down
2 changes: 1 addition & 1 deletion src/net/zmq_async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ namespace net { namespace zmq
}
}

expect<async_client> async_client::make(boost::asio::io_service& io, socket zsock)
expect<async_client> async_client::make(boost::asio::io_context& io, socket zsock)
{
MONERO_PRECOND(zsock != nullptr);

Expand Down
8 changes: 4 additions & 4 deletions src/net/zmq_async.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#pragma once

#include <boost/asio/compose.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/posix/stream_descriptor.hpp>
#include <boost/system/error_code.hpp>
#include <cstddef>
Expand Down Expand Up @@ -63,7 +63,7 @@ namespace net { namespace zmq
asocket asock;
bool close;

static expect<async_client> make(boost::asio::io_service& io, socket zsock);
static expect<async_client> make(boost::asio::io_context& io, socket zsock);
};

class read_msg_op
Expand Down Expand Up @@ -94,7 +94,7 @@ namespace net { namespace zmq
return self.complete(make_error_code(msg.error()), 0);

// try again
sock_->asock->async_read_some(boost::asio::null_buffers(), std::move(self));
sock_->asock->async_wait(boost::asio::posix::stream_descriptor::wait_read, std::move(self));
return;
}

Expand Down Expand Up @@ -133,7 +133,7 @@ namespace net { namespace zmq
return self.complete(make_error_code(status.error()), 0);

// try again
sock_->asock->async_write_some(boost::asio::null_buffers(), std::move(self));
sock_->asock->async_wait(boost::asio::posix::stream_descriptor::wait_write, std::move(self));
return;
}

Expand Down
Loading

0 comments on commit 18b5743

Please sign in to comment.