Skip to content

Commit

Permalink
replaced boost::asio::io_service by boost::asio:io_context
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Nov 25, 2024
1 parent 5f1b312 commit 3474538
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion daemon/UPnP.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace transport
std::unique_ptr<std::thread> m_Thread;
std::condition_variable m_Started;
std::mutex m_StartedMutex;
boost::asio::io_service m_Service;
boost::asio::io_context m_Service;
boost::asio::deadline_timer m_Timer;
bool m_upnpUrlsInitialized = false;
struct UPNPUrls m_upnpUrls;
Expand Down
4 changes: 2 additions & 2 deletions libi2pd/Destination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace i2p
{
namespace client
{
LeaseSetDestination::LeaseSetDestination (boost::asio::io_service& service,
LeaseSetDestination::LeaseSetDestination (boost::asio::io_context& service,
bool isPublic, const std::map<std::string, std::string> * params):
m_Service (service), m_IsPublic (isPublic), m_PublishReplyToken (0),
m_LastSubmissionTime (0), m_PublishConfirmationTimer (m_Service),
Expand Down Expand Up @@ -1000,7 +1000,7 @@ namespace client
return i2p::data::CRYPTO_KEY_TYPE_ELGAMAL;
}

ClientDestination::ClientDestination (boost::asio::io_service& service, const i2p::data::PrivateKeys& keys,
ClientDestination::ClientDestination (boost::asio::io_context& service, const i2p::data::PrivateKeys& keys,
bool isPublic, const std::map<std::string, std::string> * params):
LeaseSetDestination (service, isPublic, params),
m_Keys (keys), m_StreamingAckDelay (DEFAULT_INITIAL_ACK_DELAY),
Expand Down
10 changes: 5 additions & 5 deletions libi2pd/Destination.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace client
// leaseSet = nullptr means not found
struct LeaseSetRequest
{
LeaseSetRequest (boost::asio::io_service& service): requestTime (0), requestTimeoutTimer (service) {};
LeaseSetRequest (boost::asio::io_context& service): requestTime (0), requestTimeoutTimer (service) {};
std::unordered_set<i2p::data::IdentHash> excluded;
uint64_t requestTime;
boost::asio::deadline_timer requestTimeoutTimer;
Expand All @@ -125,10 +125,10 @@ namespace client

public:

LeaseSetDestination (boost::asio::io_service& service, bool isPublic, const std::map<std::string, std::string> * params = nullptr);
LeaseSetDestination (boost::asio::io_context& service, bool isPublic, const std::map<std::string, std::string> * params = nullptr);
~LeaseSetDestination ();
const std::string& GetNickname () const { return m_Nickname; };
boost::asio::io_service& GetService () { return m_Service; };
auto& GetService () { return m_Service; };

virtual void Start ();
virtual void Stop ();
Expand Down Expand Up @@ -195,7 +195,7 @@ namespace client

private:

boost::asio::io_service& m_Service;
boost::asio::io_context& m_Service;
mutable std::mutex m_RemoteLeaseSetsMutex;
std::unordered_map<i2p::data::IdentHash, std::shared_ptr<i2p::data::LeaseSet> > m_RemoteLeaseSets;
std::unordered_map<i2p::data::IdentHash, std::shared_ptr<LeaseSetRequest> > m_LeaseSetRequests;
Expand Down Expand Up @@ -241,7 +241,7 @@ namespace client

public:

ClientDestination (boost::asio::io_service& service, const i2p::data::PrivateKeys& keys,
ClientDestination (boost::asio::io_context& service, const i2p::data::PrivateKeys& keys,
bool isPublic, const std::map<std::string, std::string> * params = nullptr);
~ClientDestination ();

Expand Down
2 changes: 1 addition & 1 deletion libi2pd/NTCP2.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ namespace transport

void Start ();
void Stop ();
boost::asio::io_service& GetService () { return GetIOService (); };
auto& GetService () { return GetIOService (); };
std::mt19937& GetRng () { return m_Rng; };

bool AddNTCP2Session (std::shared_ptr<NTCP2Session> session, bool incoming = false);
Expand Down
4 changes: 2 additions & 2 deletions libi2pd/Reseed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ namespace data
if (!url.port)
url.port = 443;

boost::asio::io_service service;
boost::asio::io_context service;
boost::system::error_code ecode;

boost::asio::ssl::context ctx(boost::asio::ssl::context::sslv23);
Expand Down Expand Up @@ -746,7 +746,7 @@ namespace data
if (!url.port) url.port = 80;

boost::system::error_code ecode;
boost::asio::io_service service;
boost::asio::io_context service;
boost::asio::ip::tcp::socket s(service, boost::asio::ip::tcp::v6());

auto it = boost::asio::ip::tcp::resolver(service).resolve (
Expand Down
4 changes: 2 additions & 2 deletions libi2pd/SSU2.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace transport
public:

ReceiveService (const std::string& name): RunnableService (name) {};
boost::asio::io_service& GetService () { return GetIOService (); };
auto& GetService () { return GetIOService (); };
void Start () { StartIOService (); };
void Stop () { StopIOService (); };
};
Expand All @@ -73,7 +73,7 @@ namespace transport

void Start ();
void Stop ();
boost::asio::io_service& GetService () { return GetIOService (); };
auto& GetService () { return GetIOService (); };
void SetLocalAddress (const boost::asio::ip::address& localAddress);
bool SetProxy (const std::string& address, uint16_t port);
bool UsesProxy () const { return m_IsThroughProxy; };
Expand Down
4 changes: 2 additions & 2 deletions libi2pd/Streaming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace stream
}
}

Stream::Stream (boost::asio::io_service& service, StreamingDestination& local,
Stream::Stream (boost::asio::io_context& service, StreamingDestination& local,
std::shared_ptr<const i2p::data::LeaseSet> remote, int port): m_Service (service),
m_SendStreamID (0), m_SequenceNumber (0), m_DropWindowDelaySequenceNumber (0),
m_TunnelsChangeSequenceNumber (0), m_LastReceivedSequenceNumber (-1), m_PreviousReceivedSequenceNumber (-1),
Expand Down Expand Up @@ -95,7 +95,7 @@ namespace stream
m_PacketACKInterval = (1000000LL*STREAMING_MTU)/inboundSpeed;
}

Stream::Stream (boost::asio::io_service& service, StreamingDestination& local):
Stream::Stream (boost::asio::io_context& service, StreamingDestination& local):
m_Service (service), m_SendStreamID (0), m_SequenceNumber (0), m_DropWindowDelaySequenceNumber (0),
m_TunnelsChangeSequenceNumber (0), m_LastReceivedSequenceNumber (-1), m_PreviousReceivedSequenceNumber (-1),
m_LastConfirmedReceivedSequenceNumber (0), // for limit inbound speed
Expand Down
6 changes: 3 additions & 3 deletions libi2pd/Streaming.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ namespace stream
{
public:

Stream (boost::asio::io_service& service, StreamingDestination& local,
Stream (boost::asio::io_context& service, StreamingDestination& local,
std::shared_ptr<const i2p::data::LeaseSet> remote, int port = 0); // outgoing
Stream (boost::asio::io_service& service, StreamingDestination& local); // incoming
Stream (boost::asio::io_context& service, StreamingDestination& local); // incoming

~Stream ();
uint32_t GetSendStreamID () const { return m_SendStreamID; };
Expand Down Expand Up @@ -255,7 +255,7 @@ namespace stream

private:

boost::asio::io_service& m_Service;
boost::asio::io_context& m_Service;
uint32_t m_SendStreamID, m_RecvStreamID, m_SequenceNumber;
uint32_t m_DropWindowDelaySequenceNumber;
uint32_t m_TunnelsChangeSequenceNumber;
Expand Down
2 changes: 1 addition & 1 deletion libi2pd/Timestamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace util
static void SyncTimeWithNTP (const std::string& address)
{
LogPrint (eLogInfo, "Timestamp: NTP request to ", address);
boost::asio::io_service service;
boost::asio::io_context service;
boost::system::error_code ec;
auto it = boost::asio::ip::udp::resolver (service).resolve (
boost::asio::ip::udp::resolver::query (address, "ntp"), ec);
Expand Down
2 changes: 1 addition & 1 deletion libi2pd/Timestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace util

bool m_IsRunning;
std::unique_ptr<std::thread> m_Thread;
boost::asio::io_service m_Service;
boost::asio::io_context m_Service;
boost::asio::deadline_timer m_Timer;
int m_SyncInterval;
std::vector<std::string> m_NTPServersList;
Expand Down
4 changes: 2 additions & 2 deletions libi2pd/Transports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ namespace transport
{
if (!m_Service)
{
m_Service = new boost::asio::io_service ();
m_Work = new boost::asio::io_service::work (*m_Service);
m_Service = new boost::asio::io_context ();
m_Work = new boost::asio::io_context::work (*m_Service);
m_PeerCleanupTimer = new boost::asio::deadline_timer (*m_Service);
m_PeerTestTimer = new boost::asio::deadline_timer (*m_Service);
m_UpdateBandwidthTimer = new boost::asio::deadline_timer (*m_Service);
Expand Down
6 changes: 3 additions & 3 deletions libi2pd/Transports.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ namespace transport
bool IsOnline() const { return m_IsOnline; };
void SetOnline (bool online);

boost::asio::io_service& GetService () { return *m_Service; };
auto& GetService () { return *m_Service; };
std::shared_ptr<i2p::crypto::X25519Keys> GetNextX25519KeysPair ();
void ReuseX25519KeysPair (std::shared_ptr<i2p::crypto::X25519Keys> pair);

Expand Down Expand Up @@ -207,8 +207,8 @@ namespace transport
volatile bool m_IsOnline;
bool m_IsRunning, m_IsNAT, m_CheckReserved;
std::thread * m_Thread;
boost::asio::io_service * m_Service;
boost::asio::io_service::work * m_Work;
boost::asio::io_context * m_Service;
boost::asio::io_context::work * m_Work;
boost::asio::deadline_timer * m_PeerCleanupTimer, * m_PeerTestTimer, * m_UpdateBandwidthTimer;

SSU2Server * m_SSU2Server;
Expand Down
6 changes: 3 additions & 3 deletions libi2pd/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ namespace util
RunnableService (const std::string& name): m_Name (name), m_IsRunning (false) {}
virtual ~RunnableService () {}

boost::asio::io_service& GetIOService () { return m_Service; }
auto& GetIOService () { return m_Service; }
bool IsRunning () const { return m_IsRunning; };

void StartIOService ();
Expand All @@ -194,7 +194,7 @@ namespace util
std::string m_Name;
volatile bool m_IsRunning;
std::unique_ptr<std::thread> m_Thread;
boost::asio::io_service m_Service;
boost::asio::io_context m_Service;
};

class RunnableServiceWithWork: public RunnableService
Expand All @@ -206,7 +206,7 @@ namespace util

private:

boost::asio::io_service::work m_Work;
boost::asio::io_context::work m_Work;
};

void SetThreadName (const char *name);
Expand Down
4 changes: 2 additions & 2 deletions libi2pd_client/BOB.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2023, The PurpleI2P Project
* Copyright (c) 2013-2024, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
Expand Down Expand Up @@ -254,7 +254,7 @@ namespace client
void Start ();
void Stop ();

boost::asio::io_service& GetService () { return GetIOService (); };
auto& GetService () { return GetIOService (); };
void AddDestination (const std::string& name, std::shared_ptr<BOBDestination> dest);
void DeleteDestination (const std::string& name);
std::shared_ptr<BOBDestination> FindDestination (const std::string& name);
Expand Down
4 changes: 2 additions & 2 deletions libi2pd_client/ClientContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ namespace client
}

std::shared_ptr<ClientDestination> ClientContext::CreateNewLocalDestination (
boost::asio::io_service& service, bool isPublic,
boost::asio::io_context& service, bool isPublic,
i2p::data::SigningKeyType sigType, i2p::data::CryptoKeyType cryptoType,
const std::map<std::string, std::string> * params)
{
Expand Down Expand Up @@ -399,7 +399,7 @@ namespace client
return localDestination;
}

std::shared_ptr<ClientDestination> ClientContext::CreateNewLocalDestination (boost::asio::io_service& service,
std::shared_ptr<ClientDestination> ClientContext::CreateNewLocalDestination (boost::asio::io_context& service,
const i2p::data::PrivateKeys& keys, bool isPublic, const std::map<std::string, std::string> * params)
{
auto it = m_Destinations.find (keys.GetPublic ()->GetIdentHash ());
Expand Down
4 changes: 2 additions & 2 deletions libi2pd_client/ClientContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ namespace client
i2p::data::SigningKeyType sigType = i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519,
i2p::data::CryptoKeyType cryptoType = i2p::data::CRYPTO_KEY_TYPE_ELGAMAL,
const std::map<std::string, std::string> * params = nullptr); // used by SAM only
std::shared_ptr<ClientDestination> CreateNewLocalDestination (boost::asio::io_service& service,
std::shared_ptr<ClientDestination> CreateNewLocalDestination (boost::asio::io_context& service,
bool isPublic = false, i2p::data::SigningKeyType sigType = i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519,
i2p::data::CryptoKeyType cryptoType = i2p::data::CRYPTO_KEY_TYPE_ELGAMAL,
const std::map<std::string, std::string> * params = nullptr); // same as previous but on external io_service
std::shared_ptr<ClientDestination> CreateNewLocalDestination (const i2p::data::PrivateKeys& keys, bool isPublic = true,
const std::map<std::string, std::string> * params = nullptr);
std::shared_ptr<ClientDestination> CreateNewLocalDestination (boost::asio::io_service& service,
std::shared_ptr<ClientDestination> CreateNewLocalDestination (boost::asio::io_context& service,
const i2p::data::PrivateKeys& keys, bool isPublic = true,
const std::map<std::string, std::string> * params = nullptr); // same as previous but on external io_service
std::shared_ptr<ClientDestination> CreateNewMatchedTunnelDestination(const i2p::data::PrivateKeys &keys,
Expand Down
2 changes: 1 addition & 1 deletion libi2pd_client/I2CP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace i2p
namespace client
{

I2CPDestination::I2CPDestination (boost::asio::io_service& service, std::shared_ptr<I2CPSession> owner,
I2CPDestination::I2CPDestination (boost::asio::io_context& service, std::shared_ptr<I2CPSession> owner,
std::shared_ptr<const i2p::data::IdentityEx> identity, bool isPublic, bool isSameThread,
const std::map<std::string, std::string>& params):
LeaseSetDestination (service, isPublic, &params),
Expand Down
4 changes: 2 additions & 2 deletions libi2pd_client/I2CP.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace client
{
public:

I2CPDestination (boost::asio::io_service& service, std::shared_ptr<I2CPSession> owner,
I2CPDestination (boost::asio::io_context& service, std::shared_ptr<I2CPSession> owner,
std::shared_ptr<const i2p::data::IdentityEx> identity, bool isPublic, bool isSameThread,
const std::map<std::string, std::string>& params);
~I2CPDestination () {};
Expand Down Expand Up @@ -227,7 +227,7 @@ namespace client

void Start ();
void Stop ();
boost::asio::io_service& GetService () { return GetIOService (); };
auto& GetService () { return GetIOService (); };
bool IsSingleThread () const { return m_IsSingleThread; };

bool InsertSession (std::shared_ptr<I2CPSession> session);
Expand Down
2 changes: 1 addition & 1 deletion libi2pd_client/I2PService.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace client
}
void CreateStream (StreamRequestComplete streamRequestComplete, const std::string& dest, uint16_t port = 0);
void CreateStream(StreamRequestComplete complete, std::shared_ptr<const Address> address, uint16_t port);
inline boost::asio::io_service& GetService () { return m_LocalDestination->GetService (); }
auto& GetService () { return m_LocalDestination->GetService (); }

virtual void Start () = 0;
virtual void Stop () = 0;
Expand Down
2 changes: 1 addition & 1 deletion libi2pd_client/SAM.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ namespace client
void Start ();
void Stop ();

boost::asio::io_service& GetService () { return GetIOService (); };
auto& GetService () { return GetIOService (); };
std::shared_ptr<SAMSession> CreateSession (const std::string& id, SAMSessionType type, const std::string& destination, // empty string means transient
const std::map<std::string, std::string> * params);
bool AddSession (std::shared_ptr<SAMSession> session);
Expand Down

0 comments on commit 3474538

Please sign in to comment.