Skip to content

Commit

Permalink
Use spaceship everywhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
szmyd committed Sep 22, 2023
1 parent 427ed24 commit 5c1efd0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/include/homeobject/pg_manager.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <compare>
#include <set>
#include <string>

Expand All @@ -17,6 +18,10 @@ struct PGMember {
peer_id id;
std::string name;
int32_t priority{0}; // <0 (Arbiter), ==0 (Follower), >0 (F|Leader)

auto operator<=>(PGMember const& rhs) const {
return boost::uuids::hash_value(id) <=> boost::uuids::hash_value(rhs.id);
}
};

using MemberSet = std::set< PGMember >;
Expand All @@ -25,6 +30,8 @@ struct PGInfo {
explicit PGInfo(pg_id _id) : id(_id) {}
pg_id id;
mutable MemberSet members;

auto operator<=>(PGInfo const& rhs) const { return id <=> rhs.id; }
};

class PGManager : public Manager< PGError > {
Expand All @@ -33,7 +40,4 @@ class PGManager : public Manager< PGError > {
virtual NullAsyncResult replace_member(pg_id id, peer_id const& old_member, PGMember const& new_member) = 0;
};

inline bool operator<(homeobject::PGMember const& lhs, homeobject::PGMember const& rhs) { return lhs.id < rhs.id; }
inline bool operator<(homeobject::PGInfo const& lhs, homeobject::PGInfo const& rhs) { return lhs.id < rhs.id; }

} // namespace homeobject
3 changes: 3 additions & 0 deletions src/include/homeobject/shard_manager.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <compare>
#include <list>
#include <optional>

Expand Down Expand Up @@ -26,6 +27,8 @@ struct ShardInfo {
uint64_t total_capacity_bytes;
uint64_t deleted_capacity_bytes;
std::optional< peer_id > current_leader{std::nullopt};

auto operator<=>(ShardInfo const& rhs) const { return id <=> rhs.id; }
};

using InfoList = std::list< ShardInfo >;
Expand Down
1 change: 1 addition & 0 deletions src/lib/blob_route.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <compare>
#include <functional>

#include <boost/functional/hash.hpp>
Expand Down
3 changes: 0 additions & 3 deletions src/lib/homeobject_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ constexpr size_t shard_mask = std::numeric_limits< homeobject::shard_id >::max()

inline shard_id make_new_shard_id(pg_id pg, shard_id next_shard) { return ((uint64_t)pg << shard_width) | next_shard; }

inline bool operator<(ShardInfo const& lhs, ShardInfo const& rhs) { return lhs.id < rhs.id; }
inline bool operator==(ShardInfo const& lhs, ShardInfo const& rhs) { return lhs.id == rhs.id; }

struct Shard {
explicit Shard(ShardInfo info) : info(std::move(info)) {}
ShardInfo info;
Expand Down

0 comments on commit 5c1efd0

Please sign in to comment.