0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-15 22:41:12 +01:00

ircd::db: Fix additional db::prefetcher shutdown. (related cd15c17499)

This commit is contained in:
Jason Volk 2022-07-13 12:46:51 -07:00
parent 994702b32f
commit 084bef0579
2 changed files with 19 additions and 26 deletions

View file

@ -28,7 +28,7 @@ struct ircd::db::prefetcher
ctx::context context; ctx::context context;
size_t request_workers {0}; size_t request_workers {0};
size_t wait_pending(); private:
void request_handle(request &); void request_handle(request &);
size_t request_cleanup() noexcept; size_t request_cleanup() noexcept;
void request_worker(); void request_worker();
@ -36,6 +36,7 @@ struct ircd::db::prefetcher
void worker(); void worker();
public: public:
size_t wait_pending();
size_t cancel(const closure &); size_t cancel(const closure &);
size_t cancel(database &); // Cancel all for db size_t cancel(database &); // Cancel all for db
size_t cancel(column &); // Cancel all for column size_t cancel(column &); // Cancel all for column

View file

@ -682,6 +682,23 @@ ircd::db::prefetcher::cancel(const closure &closure)
return canceled; return canceled;
} }
size_t
ircd::db::prefetcher::wait_pending()
{
const size_t fetched
{
ticker->fetched
};
dock.wait([this, &fetched]() noexcept
{
return this->ticker->fetched >= fetched + this->request_workers;
});
assert(ticker->fetched >= fetched);
return ticker->fetched - fetched;
}
void void
ircd::db::prefetcher::worker() ircd::db::prefetcher::worker()
try try
@ -875,31 +892,6 @@ catch(...)
throw; throw;
} }
size_t
ircd::db::prefetcher::wait_pending()
{
const size_t fetched_counter
{
ticker->fetched
};
const size_t fetched_target
{
fetched_counter + request_workers
};
dock.wait([this, &fetched_target]() noexcept
{
return false
|| this->ticker->fetched >= fetched_target
|| !request_workers
;
});
assert(fetched_target >= fetched_counter);
return fetched_target - fetched_counter;
}
// //
// prefetcher::request // prefetcher::request
// //