mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Replace boost locks and mutexes with std-equivalent
This commit is contained in:
@@ -29,9 +29,8 @@
|
|||||||
#include <ripple/protocol/PublicKey.h>
|
#include <ripple/protocol/PublicKey.h>
|
||||||
#include <boost/iterator/counting_iterator.hpp>
|
#include <boost/iterator/counting_iterator.hpp>
|
||||||
#include <boost/range/adaptors.hpp>
|
#include <boost/range/adaptors.hpp>
|
||||||
#include <boost/thread/locks.hpp>
|
|
||||||
#include <boost/thread/shared_mutex.hpp>
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <shared_mutex>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
@@ -129,7 +128,7 @@ class ValidatorList
|
|||||||
ManifestCache& publisherManifests_;
|
ManifestCache& publisherManifests_;
|
||||||
TimeKeeper& timeKeeper_;
|
TimeKeeper& timeKeeper_;
|
||||||
beast::Journal j_;
|
beast::Journal j_;
|
||||||
boost::shared_mutex mutable mutex_;
|
std::shared_timed_mutex mutable mutex_;
|
||||||
|
|
||||||
std::atomic<std::size_t> quorum_;
|
std::atomic<std::size_t> quorum_;
|
||||||
boost::optional<std::size_t> minimumQuorum_;
|
boost::optional<std::size_t> minimumQuorum_;
|
||||||
|
|||||||
@@ -26,6 +26,9 @@
|
|||||||
#include <boost/beast/core/detail/base64.hpp>
|
#include <boost/beast/core/detail/base64.hpp>
|
||||||
#include <boost/regex.hpp>
|
#include <boost/regex.hpp>
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
#include <shared_mutex>
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
@@ -82,7 +85,7 @@ ValidatorList::load (
|
|||||||
")?" // end optional comment block
|
")?" // end optional comment block
|
||||||
);
|
);
|
||||||
|
|
||||||
boost::unique_lock<boost::shared_mutex> read_lock{mutex_};
|
std::unique_lock<std::shared_timed_mutex> read_lock{mutex_};
|
||||||
|
|
||||||
JLOG (j_.debug()) <<
|
JLOG (j_.debug()) <<
|
||||||
"Loading configured trusted validator list publisher keys";
|
"Loading configured trusted validator list publisher keys";
|
||||||
@@ -198,7 +201,7 @@ ValidatorList::applyList (
|
|||||||
if (version != requiredListVersion)
|
if (version != requiredListVersion)
|
||||||
return ListDisposition::unsupported_version;
|
return ListDisposition::unsupported_version;
|
||||||
|
|
||||||
boost::unique_lock<boost::shared_mutex> lock{mutex_};
|
std::unique_lock<std::shared_timed_mutex> lock{mutex_};
|
||||||
|
|
||||||
Json::Value list;
|
Json::Value list;
|
||||||
PublicKey pubKey;
|
PublicKey pubKey;
|
||||||
@@ -376,7 +379,7 @@ bool
|
|||||||
ValidatorList::listed (
|
ValidatorList::listed (
|
||||||
PublicKey const& identity) const
|
PublicKey const& identity) const
|
||||||
{
|
{
|
||||||
boost::shared_lock<boost::shared_mutex> read_lock{mutex_};
|
std::shared_lock<std::shared_timed_mutex> read_lock{mutex_};
|
||||||
|
|
||||||
auto const pubKey = validatorManifests_.getMasterKey (identity);
|
auto const pubKey = validatorManifests_.getMasterKey (identity);
|
||||||
return keyListings_.find (pubKey) != keyListings_.end ();
|
return keyListings_.find (pubKey) != keyListings_.end ();
|
||||||
@@ -385,7 +388,7 @@ ValidatorList::listed (
|
|||||||
bool
|
bool
|
||||||
ValidatorList::trusted (PublicKey const& identity) const
|
ValidatorList::trusted (PublicKey const& identity) const
|
||||||
{
|
{
|
||||||
boost::shared_lock<boost::shared_mutex> read_lock{mutex_};
|
std::shared_lock<std::shared_timed_mutex> read_lock{mutex_};
|
||||||
|
|
||||||
auto const pubKey = validatorManifests_.getMasterKey (identity);
|
auto const pubKey = validatorManifests_.getMasterKey (identity);
|
||||||
return trustedKeys_.find (pubKey) != trustedKeys_.end();
|
return trustedKeys_.find (pubKey) != trustedKeys_.end();
|
||||||
@@ -395,7 +398,7 @@ boost::optional<PublicKey>
|
|||||||
ValidatorList::getListedKey (
|
ValidatorList::getListedKey (
|
||||||
PublicKey const& identity) const
|
PublicKey const& identity) const
|
||||||
{
|
{
|
||||||
boost::shared_lock<boost::shared_mutex> read_lock{mutex_};
|
std::shared_lock<std::shared_timed_mutex> read_lock{mutex_};
|
||||||
|
|
||||||
auto const pubKey = validatorManifests_.getMasterKey (identity);
|
auto const pubKey = validatorManifests_.getMasterKey (identity);
|
||||||
if (keyListings_.find (pubKey) != keyListings_.end ())
|
if (keyListings_.find (pubKey) != keyListings_.end ())
|
||||||
@@ -406,7 +409,7 @@ ValidatorList::getListedKey (
|
|||||||
boost::optional<PublicKey>
|
boost::optional<PublicKey>
|
||||||
ValidatorList::getTrustedKey (PublicKey const& identity) const
|
ValidatorList::getTrustedKey (PublicKey const& identity) const
|
||||||
{
|
{
|
||||||
boost::shared_lock<boost::shared_mutex> read_lock{mutex_};
|
std::shared_lock<std::shared_timed_mutex> read_lock{mutex_};
|
||||||
|
|
||||||
auto const pubKey = validatorManifests_.getMasterKey (identity);
|
auto const pubKey = validatorManifests_.getMasterKey (identity);
|
||||||
if (trustedKeys_.find (pubKey) != trustedKeys_.end())
|
if (trustedKeys_.find (pubKey) != trustedKeys_.end())
|
||||||
@@ -417,14 +420,14 @@ ValidatorList::getTrustedKey (PublicKey const& identity) const
|
|||||||
bool
|
bool
|
||||||
ValidatorList::trustedPublisher (PublicKey const& identity) const
|
ValidatorList::trustedPublisher (PublicKey const& identity) const
|
||||||
{
|
{
|
||||||
boost::shared_lock<boost::shared_mutex> read_lock{mutex_};
|
std::shared_lock<std::shared_timed_mutex> read_lock{mutex_};
|
||||||
return identity.size() && publisherLists_.count (identity);
|
return identity.size() && publisherLists_.count (identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
PublicKey
|
PublicKey
|
||||||
ValidatorList::localPublicKey () const
|
ValidatorList::localPublicKey () const
|
||||||
{
|
{
|
||||||
boost::shared_lock<boost::shared_mutex> read_lock{mutex_};
|
std::shared_lock<std::shared_timed_mutex> read_lock{mutex_};
|
||||||
return localPubKey_;
|
return localPubKey_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,7 +462,7 @@ ValidatorList::removePublisherList (PublicKey const& publisherKey)
|
|||||||
boost::optional<TimeKeeper::time_point>
|
boost::optional<TimeKeeper::time_point>
|
||||||
ValidatorList::expires() const
|
ValidatorList::expires() const
|
||||||
{
|
{
|
||||||
boost::shared_lock<boost::shared_mutex> read_lock{mutex_};
|
std::shared_lock<std::shared_timed_mutex> read_lock{mutex_};
|
||||||
boost::optional<TimeKeeper::time_point> res{boost::none};
|
boost::optional<TimeKeeper::time_point> res{boost::none};
|
||||||
for (auto const& p : publisherLists_)
|
for (auto const& p : publisherLists_)
|
||||||
{
|
{
|
||||||
@@ -479,7 +482,7 @@ ValidatorList::getJson() const
|
|||||||
{
|
{
|
||||||
Json::Value res(Json::objectValue);
|
Json::Value res(Json::objectValue);
|
||||||
|
|
||||||
boost::shared_lock<boost::shared_mutex> read_lock{mutex_};
|
std::shared_lock<std::shared_timed_mutex> read_lock{mutex_};
|
||||||
|
|
||||||
res[jss::validation_quorum] = static_cast<Json::UInt>(quorum());
|
res[jss::validation_quorum] = static_cast<Json::UInt>(quorum());
|
||||||
|
|
||||||
@@ -561,7 +564,7 @@ void
|
|||||||
ValidatorList::for_each_listed (
|
ValidatorList::for_each_listed (
|
||||||
std::function<void(PublicKey const&, bool)> func) const
|
std::function<void(PublicKey const&, bool)> func) const
|
||||||
{
|
{
|
||||||
boost::shared_lock<boost::shared_mutex> read_lock{mutex_};
|
std::shared_lock<std::shared_timed_mutex> read_lock{mutex_};
|
||||||
|
|
||||||
for (auto const& v : keyListings_)
|
for (auto const& v : keyListings_)
|
||||||
func (v.first, trusted(v.first));
|
func (v.first, trusted(v.first));
|
||||||
@@ -629,7 +632,7 @@ ValidatorList::calculateQuorum (
|
|||||||
TrustChanges
|
TrustChanges
|
||||||
ValidatorList::updateTrusted(hash_set<NodeID> const& seenValidators)
|
ValidatorList::updateTrusted(hash_set<NodeID> const& seenValidators)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::shared_mutex> lock{mutex_};
|
std::unique_lock<std::shared_timed_mutex> lock{mutex_};
|
||||||
|
|
||||||
// Remove any expired published lists
|
// Remove any expired published lists
|
||||||
for (auto const& list : publisherLists_)
|
for (auto const& list : publisherLists_)
|
||||||
|
|||||||
Reference in New Issue
Block a user