mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-26 22:02:15 +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};
|
||||
|
||||
for (size_t i = 0; i < this_ptr->deferred_waitables.size(); i++) {
|
||||
auto w = this_ptr->deferred_waitables[i];
|
||||
for (auto it = this_ptr->deferred_waitables.begin(); it != this_ptr->deferred_waitables.end();) {
|
||||
auto w = *it;
|
||||
Result rc = w->HandleDeferred();
|
||||
if (rc == 0xF601 || !w->IsDeferred()) {
|
||||
/* Remove from the deferred list. */
|
||||
this_ptr->deferred_waitables.erase(this_ptr->deferred_waitables.begin() + i);
|
||||
/* Remove from the deferred list, set iterator. */
|
||||
it = this_ptr->deferred_waitables.erase(it);
|
||||
if (rc == 0xF601) {
|
||||
/* Delete the closed waitable. */
|
||||
delete w;
|
||||
|
@ -173,8 +173,9 @@ class WaitableManager : public SessionManagerBase {
|
|||
/* Add to the waitables list. */
|
||||
this_ptr->AddWaitable(w);
|
||||
}
|
||||
/* Subtract one from i, to avoid skipping a deferred session. */
|
||||
i--;
|
||||
} else {
|
||||
/* Move on to the next deferred waitable. */
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue