mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 07:23:53 +01:00
ircd::db: Fix additional db::prefetcher shutdown. (related cd15c17499
)
This commit is contained in:
parent
994702b32f
commit
084bef0579
2 changed files with 19 additions and 26 deletions
|
@ -28,7 +28,7 @@ struct ircd::db::prefetcher
|
|||
ctx::context context;
|
||||
size_t request_workers {0};
|
||||
|
||||
size_t wait_pending();
|
||||
private:
|
||||
void request_handle(request &);
|
||||
size_t request_cleanup() noexcept;
|
||||
void request_worker();
|
||||
|
@ -36,6 +36,7 @@ struct ircd::db::prefetcher
|
|||
void worker();
|
||||
|
||||
public:
|
||||
size_t wait_pending();
|
||||
size_t cancel(const closure &);
|
||||
size_t cancel(database &); // Cancel all for db
|
||||
size_t cancel(column &); // Cancel all for column
|
||||
|
|
42
ircd/db.cc
42
ircd/db.cc
|
@ -682,6 +682,23 @@ ircd::db::prefetcher::cancel(const closure &closure)
|
|||
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
|
||||
ircd::db::prefetcher::worker()
|
||||
try
|
||||
|
@ -875,31 +892,6 @@ catch(...)
|
|||
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
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue