-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doc request: what modification is allowed to RawTable while holding RawIter #165
Comments
This feels like something extremely fragile to rely on since we could, for example, in the future decide to iterate backwards because we've changed our internal representation. Looking at your code, is it really necessary to process the |
Yeah, after sleeping on it, I realize that doing that would work, and do so without any impact on asymptotic complexity or space usage, and negligible impact on actual space usage. It'd still probably be nice to say what's guaranteed to work: at the least, erasing the bucket most recently yielded by the iterator needs to be allowed for |
More context on urlo and my questionable code.
What operations are allowed on
RawTable
while holding aRawIter
?Per my reading, the implementation currently suggests:
RawTable
erase
ing the most recently yieldedBucket
I would benefit from the above "delayed erasing" being guaranteed sound (for the use case linked above).
Side note: it would be useful to make
RawIter
'sdebug_assert
that it iterated all the expected items say what went wrong. Something simple like "exhausted iterator before expected; this likely indicates modification of a hash table while iterating it, which is UB" would definitely make hitting that assertion more obvious than the default message of "200 != 0" from inside of hashbrown's internals.The text was updated successfully, but these errors were encountered: