-
Notifications
You must be signed in to change notification settings - Fork 62
Remove double locking in prepareForWrite
#771
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
Conversation
The same check is performed later so the first locking is unnecessary
|
I was looking at this some time ago and was a bit confused. From what I understood the idea was to have a faster look-up and possibly slower modification, right?
There is another double locking for link collections: podio/include/podio/detail/LinkCollectionImpl.h Lines 263 to 282 in aa5927b
|
|
It has been some time since I wrote this, so I am also no longer entirely sure whether the double locking is necessary. At the time I thought it is.
So all of this is less of an optimization, but rather making sure that |
Then single lock is enough, thread 2 can't even read |
|
I also removed it in |
tmadlener
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks :)
BEGINRELEASENOTES
prepareForWrite; acquire the lock only onceENDRELEASENOTES
I think this double locking is unnecessary. The first time the mutex is locked only a check is performed that is also done anyway the second time, so locking once should be enough. In addition there is a test specifically for this that passes:
podio/tests/unittests/unittest.cpp
Line 345 in aa5927b
Added originally in #295