Revert "Fixed an occasional crash resulting from multi-thread access of the image cache"
This reverts commit 6d0b7c8424
. 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).
This commit is contained in:
parent
bf92dbbfd2
commit
b8ad791a1d
1 changed files with 1 additions and 9 deletions
|
@ -43,7 +43,6 @@
|
|||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/functional/hash_fwd.hpp>
|
||||
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
|
||||
static lg::log_domain log_display("display");
|
||||
|
@ -108,30 +107,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…
Add table
Reference in a new issue