OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LRUEvictionAlgorithm.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
32 #pragma once
33 
34 #include <cstddef>
35 #include <list>
36 #include "CacheEvictionAlgorithm.h"
38 
40  public:
41  ~LRUEvictionAlgorithm() override {}
42  // Returns the next chunk to evict and evicts.
43  const ChunkKey evictNextChunk() override;
44  // Update the algorithm knowing that this chunk was recently touched by the system.
45  void touchChunk(const ChunkKey&) override;
46  // Removes a chunk from the eviction queue if present.
47  void removeChunk(const ChunkKey&) override;
48  // Used for debugging.
49  std::string dumpEvictionQueue();
50 
51  private:
52  std::list<ChunkKey> cache_items_list_;
53  std::map<const ChunkKey, std::list<ChunkKey>::iterator> cache_items_map_;
55 };
heavyai::shared_mutex cache_mutex_
std::vector< int > ChunkKey
Definition: types.h:36
std::list< ChunkKey > cache_items_list_
const ChunkKey evictNextChunk() override
void touchChunk(const ChunkKey &) override
std::map< const ChunkKey, std::list< ChunkKey >::iterator > cache_items_map_
void removeChunk(const ChunkKey &) override
This file includes the class specification for the cache eviction algorithm interface used by the For...
std::shared_timed_mutex shared_mutex