reader_concurrency_semaphore: add initial_resources()

To allow tests to reliably calculate the amount of resources they need
to consume in order to effectively reduce the resources of the semaphore
to a desired amount. Using `available_resources()` is not reliable as it
doesn't factor in resources that are consumed at the moment but will be
returned later.
This will also benefit debugging coredumps where we will now be able to
tell how much resources the semaphore was created with and this
calculate the amount of memory and count currently used.
This commit is contained in:
Botond Dénes
2020-07-10 12:09:17 +03:00
parent f264d2b00f
commit aabbdc34ac

View File

@@ -105,6 +105,7 @@ private:
};
private:
const resources _initial_resources;
resources _resources;
expiring_fifo<entry, expiry_handler, db::timeout_clock> _wait_list;
@@ -135,7 +136,8 @@ public:
sstring name,
size_t max_queue_length = std::numeric_limits<size_t>::max(),
std::function<void()> prethrow_action = nullptr)
: _resources(count, memory)
: _initial_resources(count, memory)
, _resources(count, memory)
, _wait_list(expiry_handler(name))
, _name(std::move(name))
, _max_queue_length(max_queue_length)
@@ -193,6 +195,10 @@ public:
reader_permit make_permit();
const resources initial_resources() const {
return _initial_resources;
}
const resources available_resources() const {
return _resources;
}