Skip to content

Commit

Permalink
Fix a multithreading bug related to storing objects in the cache (#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
CNugteren authored Jul 8, 2023
1 parent 83bd474 commit 6762e84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Development version (next version)
- Fix pointer error in pyclblast on ARM
- Fix a multithreading bug related to storing objects in the cache
- Added tuned parameters for many devices (see doc/tuning.md)

Version 1.6.0
Expand Down
7 changes: 6 additions & 1 deletion src/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ void Cache<Key, Value>::Store(Key &&key, Value &&value) {
// emplace() into a map
auto r = cache_.emplace(std::move(key), std::move(value));
if (!r.second) {
throw LogicError("Cache::Store: object already in cache");
// The object is already in cache. This can happen if two threads both
// checked the cache for an object, both found that it isn't there, then
// both produced the object (e.g. a compiled binary) and try to store it
// in the cache. The first one will succeed normally, the second one will
// hit this point. We simply return in this case.
return;
}
#else
// emplace_back() into a vector
Expand Down

0 comments on commit 6762e84

Please sign in to comment.