Skip to content

Commit

Permalink
storage_proxy: make unique_response_handler friendly to small_vector
Browse files Browse the repository at this point in the history
small_vector wants the move constructor to be noexcept, and move
assighment to exist (and be noexcept). These are easy to achieve.
  • Loading branch information
avikivity committed May 9, 2021
1 parent 8398510 commit b015ded
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion service/storage_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,15 @@ storage_proxy::storage_proxy(distributed<database>& db, storage_proxy::config cf
}

storage_proxy::unique_response_handler::unique_response_handler(storage_proxy& p_, response_id_type id_) : id(id_), p(p_) {}
storage_proxy::unique_response_handler::unique_response_handler(unique_response_handler&& x) : id(x.id), p(x.p) { x.id = 0; };
storage_proxy::unique_response_handler::unique_response_handler(unique_response_handler&& x) noexcept : id(x.id), p(x.p) { x.id = 0; };

storage_proxy::unique_response_handler&
storage_proxy::unique_response_handler::operator=(unique_response_handler&& x) noexcept {
// this->p must equal x.p
id = std::exchange(x.id, 0);
return *this;
}

storage_proxy::unique_response_handler::~unique_response_handler() {
if (id) {
p.remove_response_handler(id);
Expand Down
3 changes: 2 additions & 1 deletion service/storage_proxy.hh
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ private:
unique_response_handler(storage_proxy& p_, response_id_type id_);
unique_response_handler(const unique_response_handler&) = delete;
unique_response_handler& operator=(const unique_response_handler&) = delete;
unique_response_handler(unique_response_handler&& x);
unique_response_handler(unique_response_handler&& x) noexcept;
unique_response_handler& operator=(unique_response_handler&&) noexcept;
~unique_response_handler();
response_id_type release();
};
Expand Down

0 comments on commit b015ded

Please sign in to comment.