mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-05-21 06:41:48 +02:00
use std::atomic<std::shared_ptr<...>> instead boost::shared_ptr if applicable
This commit is contained in:
parent
ba451eeca5
commit
cd648b9b3f
3 changed files with 84 additions and 66 deletions
libi2pd
|
@ -15,8 +15,11 @@
|
|||
#include <vector>
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <boost/asio.hpp>
|
||||
#ifndef __cpp_lib_atomic_shared_ptr
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#endif
|
||||
#include "Identity.h"
|
||||
#include "Profiling.h"
|
||||
#include "Family.h"
|
||||
|
@ -199,7 +202,11 @@ namespace data
|
|||
};
|
||||
|
||||
typedef std::array<std::shared_ptr<Address>, eNumTransports> Addresses;
|
||||
|
||||
#ifdef __cpp_lib_atomic_shared_ptr
|
||||
typedef std::shared_ptr<Addresses> AddressesPtr;
|
||||
#else
|
||||
typedef boost::shared_ptr<Addresses> AddressesPtr;
|
||||
#endif
|
||||
RouterInfo (const std::string& fullPath);
|
||||
RouterInfo (const RouterInfo& ) = default;
|
||||
RouterInfo& operator=(const RouterInfo& ) = default;
|
||||
|
@ -214,7 +221,7 @@ namespace data
|
|||
int GetVersion () const { return m_Version; };
|
||||
virtual void SetProperty (const std::string& key, const std::string& value) {};
|
||||
virtual void ClearProperties () {};
|
||||
boost::shared_ptr<Addresses> GetAddresses () const; // should be called for local RI only, otherwise must return shared_ptr
|
||||
AddressesPtr GetAddresses () const; // should be called for local RI only, otherwise must return shared_ptr
|
||||
std::shared_ptr<const Address> GetNTCP2V4Address () const;
|
||||
std::shared_ptr<const Address> GetNTCP2V6Address () const;
|
||||
std::shared_ptr<const Address> GetPublishedNTCP2V4Address () const;
|
||||
|
@ -333,7 +340,7 @@ namespace data
|
|||
std::shared_ptr<const Address> GetAddress (Filter filter) const;
|
||||
virtual std::shared_ptr<Buffer> NewBuffer () const;
|
||||
virtual std::shared_ptr<Address> NewAddress () const;
|
||||
virtual boost::shared_ptr<Addresses> NewAddresses () const;
|
||||
virtual AddressesPtr NewAddresses () const;
|
||||
virtual std::shared_ptr<IdentityEx> NewIdentity (const uint8_t * buf, size_t len) const;
|
||||
|
||||
private:
|
||||
|
@ -342,7 +349,11 @@ namespace data
|
|||
std::shared_ptr<const IdentityEx> m_RouterIdentity;
|
||||
std::shared_ptr<Buffer> m_Buffer;
|
||||
uint64_t m_Timestamp; // in milliseconds
|
||||
boost::shared_ptr<Addresses> m_Addresses; // TODO: use std::shared_ptr and std::atomic_store for gcc >= 4.9
|
||||
#ifdef __cpp_lib_atomic_shared_ptr
|
||||
std::atomic<AddressesPtr> m_Addresses;
|
||||
#else
|
||||
AddressesPtr m_Addresses;
|
||||
#endif
|
||||
bool m_IsUpdated, m_IsUnreachable, m_IsFloodfill;
|
||||
CompatibleTransports m_SupportedTransports, m_ReachableTransports, m_PublishedTransports;
|
||||
uint8_t m_Caps;
|
||||
|
@ -377,7 +388,7 @@ namespace data
|
|||
void WriteString (const std::string& str, std::ostream& s) const;
|
||||
std::shared_ptr<Buffer> NewBuffer () const override;
|
||||
std::shared_ptr<Address> NewAddress () const override;
|
||||
boost::shared_ptr<Addresses> NewAddresses () const override;
|
||||
RouterInfo::AddressesPtr NewAddresses () const override;
|
||||
std::shared_ptr<IdentityEx> NewIdentity (const uint8_t * buf, size_t len) const override;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue