mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-07 11:46:50 +00:00
Revert "Fixed an occasional crash resulting from multi-thread access of the image cache"
This reverts commit 6d0b7c84243aba8444f5e722cd855feed3501f12. Turns out there's a better way to fix this problem without using mutexes, which have a noticeable performance hit (5.2% of the execution time of game_display::draw_invalidated() according to @jyrkive). (cherry-picked from commit b8ad791a1d8d1e76d921d4f48a6fd57aee3c134e)
This commit is contained in:
parent
a5b8053340
commit
1ec69044fb
@ -41,7 +41,6 @@
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/functional/hash_fwd.hpp>
|
||||
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
|
||||
static lg::log_domain log_display("display");
|
||||
@ -106,30 +105,23 @@ class cache_type
|
||||
public:
|
||||
cache_type()
|
||||
: content_()
|
||||
, cache_lock_()
|
||||
{
|
||||
}
|
||||
|
||||
cache_item<T>& get_element(int index)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(cache_lock_);
|
||||
|
||||
if(static_cast<unsigned>(index) >= content_.size()) {
|
||||
if(static_cast<unsigned>(index) >= content_.size())
|
||||
content_.resize(index + 1);
|
||||
}
|
||||
|
||||
return content_[index];
|
||||
}
|
||||
|
||||
void flush()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(cache_lock_);
|
||||
content_.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<cache_item<T>> content_;
|
||||
std::mutex cache_lock_;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
Loading…
x
Reference in New Issue
Block a user