mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +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)
|
||||
{
|
||||
assert(system && system->head);
|
||||
const size_t max(system->head->nr);
|
||||
std::atomic_signal_fence(std::memory_order_acquire);
|
||||
for(auto i(system->head->head); i != system->head->tail; ++i)
|
||||
if(!closure(*reinterpret_cast<const request *>(system->ring[i % max].data)))
|
||||
const auto &max{system->head->nr};
|
||||
volatile auto head(system->head->head);
|
||||
volatile const auto &tail(system->head->tail);
|
||||
for(; head != tail; ++head, head %= max)
|
||||
if(!closure(*reinterpret_cast<const request *>(system->ring[head].data)))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue