mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-16 03:12:43 +00:00
Apply TSA
This commit is contained in:
parent
7297a29d3a
commit
8e22b6a968
@ -180,10 +180,8 @@ void QueryResultCache::Writer::buffer(Chunk && chunk)
|
||||
|
||||
}
|
||||
|
||||
QueryResultCache::Reader::Reader(const Cache & cache_, std::mutex & mutex_, const Key & key)
|
||||
QueryResultCache::Reader::Reader(const Cache & cache_, const Key & key)
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
|
||||
auto it = cache_.find(key);
|
||||
|
||||
if (it == cache_.end())
|
||||
@ -232,11 +230,13 @@ QueryResultCache::QueryResultCache(size_t max_cache_size_in_bytes_, size_t max_c
|
||||
|
||||
QueryResultCache::Reader QueryResultCache::createReader(const Key & key)
|
||||
{
|
||||
return Reader(cache, mutex, key);
|
||||
std::lock_guard lock(mutex);
|
||||
return Reader(cache, key);
|
||||
}
|
||||
|
||||
QueryResultCache::Writer QueryResultCache::createWriter(const Key & key, std::chrono::milliseconds min_query_duration)
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
return Writer(mutex, cache, key, cache_size_in_bytes, max_cache_size_in_bytes, max_cache_entries, max_cache_entry_size_in_bytes, max_cache_entry_size_in_rows, min_query_duration);
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ public:
|
||||
bool hasCacheEntryForKey() const;
|
||||
Pipe && getPipe();
|
||||
private:
|
||||
Reader(const Cache & cache_, std::mutex & mutex, const Key & key);
|
||||
Reader(const Cache & cache_, const Key & key);
|
||||
Pipe pipe;
|
||||
friend class QueryResultCache; /// for createReader()
|
||||
};
|
||||
@ -128,10 +128,10 @@ private:
|
||||
/// associated with cache entries provide a "natural" eviction criterion. As a future TODO, we could make an expiration-based eviction
|
||||
/// policy and use that with CacheBase.
|
||||
mutable std::mutex mutex;
|
||||
Cache cache;
|
||||
TimesExecutedMap times_executed;
|
||||
Cache cache TSA_GUARDED_BY(mutex);
|
||||
TimesExecutedMap times_executed TSA_GUARDED_BY(mutex);
|
||||
|
||||
size_t cache_size_in_bytes; /// updated in each cache insert/delete
|
||||
size_t cache_size_in_bytes TSA_GUARDED_BY(mutex); /// updated in each cache insert/delete
|
||||
const size_t max_cache_size_in_bytes;
|
||||
const size_t max_cache_entries;
|
||||
const size_t max_cache_entry_size_in_bytes;
|
||||
|
Loading…
Reference in New Issue
Block a user