linkedhashmap.Iterator thread safety #141
Labels
No labels
bug
discussion
documentation
duplicate
ignore
new feature
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
golibs/gms-gods#141
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
It is indicated in the linkedhasmap.go file, the linkedhashmap as a whole, is not thread safe.
In my case, I have:
Questions:
What I try to avoid is start the loop and have an
early finishdue to an object being Removed while iterating.Any help is much appreciated
I have been digging further on the lib and found a possible issue with the implementation of doublelinkedlist and its Iterator.
outorderis[0 1 2 3 4 5 6 7 8]where the element with key9is left out.This is triggered by this if statement where the list is not supposed to be altered while the Iterator is working.
As stated, there is no thread-safety in GoDS at the moment.
Also, removing elements while using iterator can lead to undefined behavior that is not currently tackled by GoDS. Not even locking mechanisms will prevent this. This is why in those cases in other languages you might get something like a ConcurrentAccessException or ConcurrentModificationException when you attempt this (try googling these exceptions to understand why e.g. Java simply throws this exception when you try to do so).
I will personally spend more time meditating if there is any way on doing something different here than what Java did.