mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd::fs::aio: Improve stability of completion ring iteration.
This commit is contained in:
parent
d118a0e743
commit
161502452a
1 changed files with 5 additions and 4 deletions
|
@ -290,10 +290,11 @@ bool
|
||||||
ircd::fs::aio::for_each_completed(const std::function<bool (const request &)> &closure)
|
ircd::fs::aio::for_each_completed(const std::function<bool (const request &)> &closure)
|
||||||
{
|
{
|
||||||
assert(system && system->head);
|
assert(system && system->head);
|
||||||
const size_t max(system->head->nr);
|
const auto &max{system->head->nr};
|
||||||
std::atomic_signal_fence(std::memory_order_acquire);
|
volatile auto head(system->head->head);
|
||||||
for(auto i(system->head->head); i != system->head->tail; ++i)
|
volatile const auto &tail(system->head->tail);
|
||||||
if(!closure(*reinterpret_cast<const request *>(system->ring[i % max].data)))
|
for(; head != tail; ++head, head %= max)
|
||||||
|
if(!closure(*reinterpret_cast<const request *>(system->ring[head].data)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue