Replace beast::SharedPtr with std::shared_ptr

This commit is contained in:
Joe Loser
2018-05-23 21:32:59 -04:00
committed by Mike Ellery
parent 6a74d771ee
commit f0cc7c4c8d
6 changed files with 22 additions and 482 deletions

View File

@@ -20,24 +20,24 @@
#ifndef RIPPLE_PEERFINDER_LOGIC_H_INCLUDED
#define RIPPLE_PEERFINDER_LOGIC_H_INCLUDED
#include <ripple/basics/contract.h>
#include <ripple/basics/Log.h>
#include <ripple/basics/contract.h>
#include <ripple/beast/container/aged_container_utility.h>
#include <ripple/beast/net/IPAddressConversion.h>
#include <ripple/peerfinder/PeerfinderManager.h>
#include <ripple/peerfinder/impl/Bootcache.h>
#include <ripple/peerfinder/impl/Counts.h>
#include <ripple/peerfinder/impl/Fixed.h>
#include <ripple/peerfinder/impl/iosformat.h>
#include <ripple/peerfinder/impl/Handouts.h>
#include <ripple/peerfinder/impl/Livecache.h>
#include <ripple/peerfinder/impl/Reporting.h>
#include <ripple/peerfinder/impl/SlotImp.h>
#include <ripple/peerfinder/impl/Source.h>
#include <ripple/peerfinder/impl/Store.h>
#include <ripple/beast/net/IPAddressConversion.h>
#include <ripple/beast/container/aged_container_utility.h>
#include <ripple/beast/core/SharedPtr.h>
#include <ripple/peerfinder/impl/iosformat.h>
#include <functional>
#include <map>
#include <memory>
#include <set>
namespace ripple {
@@ -54,8 +54,8 @@ public:
// Maps remote endpoints to slots. Since a slot has a
// remote endpoint upon construction, this holds all counts.
//
using Slots = std::map <beast::IP::Endpoint,
std::shared_ptr <SlotImp>>;
using Slots = std::map<beast::IP::Endpoint,
std::shared_ptr<SlotImp>>;
beast::Journal m_journal;
clock_type& m_clock;
@@ -69,7 +69,7 @@ public:
// The source we are currently fetching.
// This is used to cancel I/O during program exit.
beast::SharedPtr <Source> fetchSource_;
std::shared_ptr<Source> fetchSource_;
// Configuration settings
Config config_;
@@ -78,7 +78,7 @@ public:
Counts counts_;
// A list of slots that should always be connected
std::map <beast::IP::Endpoint, Fixed> fixed_;
std::map<beast::IP::Endpoint, Fixed> fixed_;
// Live livecache from mtENDPOINTS messages
Livecache <> livecache_;
@@ -92,13 +92,13 @@ public:
// The addresses (but not port) we are connected to. This includes
// outgoing connection attempts. Note that this set can contain
// duplicates (since the port is not set)
std::multiset <beast::IP::Address> connectedAddresses_;
std::multiset<beast::IP::Address> connectedAddresses_;
// Set of public keys belonging to active peers
std::set <PublicKey> keys_;
std::set<PublicKey> keys_;
// A list of dynamic sources to consult as a fallback
std::vector <beast::SharedPtr <Source>> m_sources;
std::vector<std::shared_ptr<Source>> m_sources;
clock_type::time_point m_whenBroadcast;
@@ -971,13 +971,13 @@ public:
//--------------------------------------------------------------------------
void
addStaticSource (beast::SharedPtr <Source> const& source)
addStaticSource (std::shared_ptr<Source> const& source)
{
fetch (source);
}
void
addSource (beast::SharedPtr <Source> const& source)
addSource (std::shared_ptr<Source> const& source)
{
m_sources.push_back (source);
}
@@ -1004,7 +1004,8 @@ public:
}
// Fetch bootcache addresses from the specified source.
void fetch (beast::SharedPtr <Source> const& source)
void
fetch (std::shared_ptr<Source> const& source)
{
Source::Results results;

View File

@@ -21,7 +21,6 @@
#define RIPPLE_PEERFINDER_SOURCE_H_INCLUDED
#include <ripple/peerfinder/PeerfinderManager.h>
#include <ripple/beast/core/SharedObject.h>
#include <boost/system/error_code.hpp>
namespace ripple {
@@ -35,7 +34,7 @@ namespace PeerFinder {
be updated automatically. Another solution is to use a custom DNS server
that hands out peer IP addresses when name lookups are performed.
*/
class Source : public beast::SharedObject
class Source
{
public:
/** The results of a fetch. */

View File

@@ -61,10 +61,10 @@ private:
//------------------------------------------------------------------------------
beast::SharedPtr <Source>
std::shared_ptr<Source>
SourceStrings::New (std::string const& name, Strings const& strings)
{
return new SourceStringsImp (name, strings);
return std::make_shared<SourceStringsImp> (name, strings);
}
}

View File

@@ -21,7 +21,7 @@
#define RIPPLE_PEERFINDER_SOURCESTRINGS_H_INCLUDED
#include <ripple/peerfinder/impl/Source.h>
#include <ripple/beast/core/SharedPtr.h>
#include <memory>
namespace ripple {
namespace PeerFinder {
@@ -34,7 +34,8 @@ public:
using Strings = std::vector <std::string>;
static beast::SharedPtr <Source> New (std::string const& name, Strings const& strings);
static std::shared_ptr<Source>
New (std::string const& name, Strings const& strings);
};
}