mirror of
https://github.com/monero-project/monero.git
synced 2025-05-28 14:32:19 -04:00
Eliminate dependence on boost::interprocess #8223
In this repo, `boost::interprocess` was being used soley to make `uint32_t` operations atomic. So I replaced each instance of `boost::interprocess::ipcdetail::atomic(...)32` with `std::atomic` methods. I replaced member declarations as applicable. For example, when I needed to change a `volatile uint32_t` into a `std::atomic<uint32_t>`. Sometimes, a member was being used a boolean flag, so I replaced it with `std::atomic<bool>`. You may notice that I didn't touch `levin_client_async.h`. That is because this file is entirely unused and will be deleted in PR monero-project#8211. Additional changes from review: * Make some local variables const * Change postfix operators to prefix operators where value was not need
This commit is contained in:
parent
70ceab6c10
commit
17772ef53e
10 changed files with 43 additions and 50 deletions
|
@ -42,7 +42,6 @@
|
|||
#include <boost/thread/future.hpp>
|
||||
#include <boost/lambda/bind.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <boost/interprocess/detail/atomic.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/utility/string_ref.hpp>
|
||||
#include <functional>
|
||||
|
@ -110,7 +109,7 @@ namespace net_utils
|
|||
m_initialized(true),
|
||||
m_connected(false),
|
||||
m_deadline(m_io_service, std::chrono::steady_clock::time_point::max()),
|
||||
m_shutdowned(0),
|
||||
m_shutdowned(false),
|
||||
m_bytes_sent(0),
|
||||
m_bytes_received(0)
|
||||
{
|
||||
|
@ -435,7 +434,7 @@ namespace net_utils
|
|||
async_read(&buff[0], max_size, boost::asio::transfer_at_least(1), hndlr);
|
||||
|
||||
// Block until the asynchronous operation has completed.
|
||||
while (ec == boost::asio::error::would_block && !boost::interprocess::ipcdetail::atomic_read32(&m_shutdowned))
|
||||
while (ec == boost::asio::error::would_block && !m_shutdowned)
|
||||
{
|
||||
m_io_service.reset();
|
||||
m_io_service.run_one();
|
||||
|
@ -519,7 +518,7 @@ namespace net_utils
|
|||
async_read((char*)buff.data(), buff.size(), boost::asio::transfer_at_least(buff.size()), hndlr);
|
||||
|
||||
// Block until the asynchronous operation has completed.
|
||||
while (ec == boost::asio::error::would_block && !boost::interprocess::ipcdetail::atomic_read32(&m_shutdowned))
|
||||
while (ec == boost::asio::error::would_block && !m_shutdowned)
|
||||
{
|
||||
m_io_service.run_one();
|
||||
}
|
||||
|
@ -576,7 +575,7 @@ namespace net_utils
|
|||
m_ssl_socket->next_layer().close(ec);
|
||||
if(ec)
|
||||
MDEBUG("Problems at close: " << ec.message());
|
||||
boost::interprocess::ipcdetail::atomic_write32(&m_shutdowned, 1);
|
||||
m_shutdowned = true;
|
||||
m_connected = false;
|
||||
return true;
|
||||
}
|
||||
|
@ -685,7 +684,7 @@ namespace net_utils
|
|||
bool m_initialized;
|
||||
bool m_connected;
|
||||
boost::asio::steady_timer m_deadline;
|
||||
volatile uint32_t m_shutdowned;
|
||||
std::atomic<bool> m_shutdowned;
|
||||
std::atomic<uint64_t> m_bytes_sent;
|
||||
std::atomic<uint64_t> m_bytes_received;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue