From 28c2b54875b6ca107267b0510183ec6ef73cdc8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Botond=20D=C3=A9nes?= Date: Thu, 3 Jun 2021 16:48:10 +0300 Subject: [PATCH] mutation_reader: reader_lifecycle_policy: remove convenience methods These convenience methods are not used as much anymore and they are not even really necessary as the register/unregister inactive read API got streamlined a lot to the point where all of these "convenience methods" are just one-liners, which we can just inline into their few callers without loosing readability. --- multishard_mutation_query.cc | 4 ++-- mutation_reader.cc | 15 --------------- mutation_reader.hh | 25 ------------------------- 3 files changed, 2 insertions(+), 42 deletions(-) diff --git a/multishard_mutation_query.cc b/multishard_mutation_query.cc index ff2a7043aa..1d35ee1885 100644 --- a/multishard_mutation_query.cc +++ b/multishard_mutation_query.cc @@ -309,7 +309,7 @@ flat_mutation_reader read_context::create_reader( // The reader is either in inexistent or successful lookup state. if (rm.state == reader_state::successful_lookup) { - if (auto reader_opt = try_resume(std::move(*rm.rparts->handle))) { + if (auto reader_opt = semaphore().unregister_inactive_read(std::move(*rm.rparts->handle))) { rm.state = reader_state::used; return std::move(*reader_opt); } @@ -545,7 +545,7 @@ future<> read_context::lookup_readers() { reinterpret_cast(&semaphore))); } - auto handle = pause(semaphore, std::move(q).reader()); + auto handle = semaphore.register_inactive_read(std::move(q).reader()); return reader_meta( reader_state::successful_lookup, reader_meta::remote_parts(q.permit(), std::move(q).reader_range(), std::move(q).reader_slice(), table.read_in_progress(), diff --git a/mutation_reader.cc b/mutation_reader.cc index 52f0cd8b45..4ce59ed3a2 100644 --- a/mutation_reader.cc +++ b/mutation_reader.cc @@ -1967,21 +1967,6 @@ future<> multishard_combining_reader::close() noexcept { }); } -reader_concurrency_semaphore::inactive_read_handle -reader_lifecycle_policy::pause(reader_concurrency_semaphore& sem, flat_mutation_reader reader) { - return sem.register_inactive_read(std::move(reader)); -} - -reader_concurrency_semaphore::inactive_read_handle -reader_lifecycle_policy::pause(flat_mutation_reader reader) { - return pause(semaphore(), std::move(reader)); -} - -flat_mutation_reader_opt -reader_lifecycle_policy::try_resume(reader_concurrency_semaphore::inactive_read_handle irh) { - return semaphore().unregister_inactive_read(std::move(irh)); -} - flat_mutation_reader make_multishard_combining_reader( shared_ptr lifecycle_policy, schema_ptr schema, diff --git a/mutation_reader.hh b/mutation_reader.hh index 335d8a42b9..48b79083ec 100644 --- a/mutation_reader.hh +++ b/mutation_reader.hh @@ -442,11 +442,6 @@ public: flat_mutation_reader::tracked_buffer unconsumed_fragments; }; -protected: - // Helpers for implementations, who might wish to provide the semaphore in - // other ways than through the official `semaphore()` override. - static reader_concurrency_semaphore::inactive_read_handle pause(reader_concurrency_semaphore& sem, flat_mutation_reader reader); - public: /// Create an appropriate reader on the shard it is called on. /// @@ -486,26 +481,6 @@ public: /// /// This method will be called on the shard where the relevant reader lives. virtual reader_concurrency_semaphore& semaphore() = 0; - - /// Pause the reader. - /// - /// The purpose of pausing a reader is making it evictable while it is - /// otherwise inactive. This allows freeing up resources that are in-demand - /// by evicting these paused readers. Most notably, this allows freeing up - /// reader permits when the node is overloaded with reads. - /// This is just a helper method, it uses the semaphore returned by - /// `semaphore()` for the actual pausing. - /// \see semaphore() - reader_concurrency_semaphore::inactive_read_handle pause(flat_mutation_reader reader); - - /// Try to resume the reader. - /// - /// The optional returned will be disengaged when resuming fails. This can - /// happen if the reader was evicted while paused. - /// This is just a helper method, it uses the semaphore returned by - /// `semaphore()` for the actual pausing. - /// \see semaphore() - flat_mutation_reader_opt try_resume(reader_concurrency_semaphore::inactive_read_handle irh); }; /// Make a multishard_combining_reader.