token_metadata: Hide token_metadata_impl copy constructor
Copying of token_metadata_impl is heavy operation and it's performed internally with the help of the dedicated clone_async() method. This method, in turn, doesn't copy the whole object in its copy-ctor, but rather default-initializes it and carries the remaining fields later. Having said that, the standart copy-ctor is better to be made private and, for the sake of being more explicit, marked as shallow-copy-ctor Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
@@ -74,9 +74,13 @@ private:
|
||||
|
||||
void sort_tokens();
|
||||
|
||||
struct shallow_copy {};
|
||||
token_metadata_impl(shallow_copy, const token_metadata_impl& o) noexcept
|
||||
{}
|
||||
|
||||
public:
|
||||
token_metadata_impl() noexcept {};
|
||||
token_metadata_impl(const token_metadata_impl&) = default;
|
||||
token_metadata_impl(const token_metadata_impl&) = delete; // it's too huge for direct copy, use clone_async()
|
||||
token_metadata_impl(token_metadata_impl&&) noexcept = default;
|
||||
const std::vector<token>& sorted_tokens() const;
|
||||
future<> update_normal_tokens(std::unordered_set<token> tokens, inet_address endpoint);
|
||||
@@ -358,7 +362,7 @@ future<token_metadata_impl> token_metadata_impl::clone_async() const noexcept {
|
||||
}
|
||||
|
||||
future<token_metadata_impl> token_metadata_impl::clone_only_token_map(bool clone_sorted_tokens) const noexcept {
|
||||
return do_with(token_metadata_impl(), [this, clone_sorted_tokens] (token_metadata_impl& ret) {
|
||||
return do_with(token_metadata_impl(shallow_copy{}, *this), [this, clone_sorted_tokens] (token_metadata_impl& ret) {
|
||||
ret._token_to_endpoint_map.reserve(_token_to_endpoint_map.size());
|
||||
return do_for_each(_token_to_endpoint_map, [&ret] (const auto& p) {
|
||||
ret._token_to_endpoint_map.emplace(p);
|
||||
|
||||
Reference in New Issue
Block a user