mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2025-01-27 09:32:53 +00:00
libstrat: Use iterators when looping deferred waitables
This commit is contained in:
parent
147f3c690a
commit
8426a4dc77
1 changed files with 7 additions and 6 deletions
|
@ -160,12 +160,12 @@ class WaitableManager : public SessionManagerBase {
|
||||||
{
|
{
|
||||||
std::scoped_lock lk{this_ptr->deferred_lock};
|
std::scoped_lock lk{this_ptr->deferred_lock};
|
||||||
|
|
||||||
for (size_t i = 0; i < this_ptr->deferred_waitables.size(); i++) {
|
for (auto it = this_ptr->deferred_waitables.begin(); it != this_ptr->deferred_waitables.end();) {
|
||||||
auto w = this_ptr->deferred_waitables[i];
|
auto w = *it;
|
||||||
Result rc = w->HandleDeferred();
|
Result rc = w->HandleDeferred();
|
||||||
if (rc == 0xF601 || !w->IsDeferred()) {
|
if (rc == 0xF601 || !w->IsDeferred()) {
|
||||||
/* Remove from the deferred list. */
|
/* Remove from the deferred list, set iterator. */
|
||||||
this_ptr->deferred_waitables.erase(this_ptr->deferred_waitables.begin() + i);
|
it = this_ptr->deferred_waitables.erase(it);
|
||||||
if (rc == 0xF601) {
|
if (rc == 0xF601) {
|
||||||
/* Delete the closed waitable. */
|
/* Delete the closed waitable. */
|
||||||
delete w;
|
delete w;
|
||||||
|
@ -173,8 +173,9 @@ class WaitableManager : public SessionManagerBase {
|
||||||
/* Add to the waitables list. */
|
/* Add to the waitables list. */
|
||||||
this_ptr->AddWaitable(w);
|
this_ptr->AddWaitable(w);
|
||||||
}
|
}
|
||||||
/* Subtract one from i, to avoid skipping a deferred session. */
|
} else {
|
||||||
i--;
|
/* Move on to the next deferred waitable. */
|
||||||
|
it++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue