* @brief initialize a ClockPro cache * * @param ccache_params some common cache parameters * @param cache_specific_params Clock specific parameters as a string */
| 90 | * @param cache_specific_params Clock specific parameters as a string |
| 91 | */ |
| 92 | cache_t *ClockPro_init(const common_cache_params_t ccache_params, const char *cache_specific_params) { |
| 93 | cache_t *cache = cache_struct_init("ClockPro", ccache_params, cache_specific_params); |
| 94 | cache->cache_init = ClockPro_init; |
| 95 | cache->cache_free = ClockPro_free; |
| 96 | cache->get = ClockPro_get; |
| 97 | cache->find = ClockPro_find; |
| 98 | cache->insert = ClockPro_insert; |
| 99 | cache->evict = ClockPro_evict; |
| 100 | cache->remove = ClockPro_remove; |
| 101 | cache->can_insert = ClockPro_can_insert; |
| 102 | cache->get_n_obj = cache_get_n_obj_default; |
| 103 | cache->get_occupied_byte = cache_get_occupied_byte_default; |
| 104 | cache->obj_md_size = 0; |
| 105 | |
| 106 | cache->eviction_params = my_malloc_n(ClockPro_params_t, 1); |
| 107 | ClockPro_params_t *params = (ClockPro_params_t *)(cache->eviction_params); |
| 108 | |
| 109 | params->hand_hot = NULL; |
| 110 | params->hand_cold = NULL; |
| 111 | params->hand_test = NULL; |
| 112 | params->mem_cold = 0; |
| 113 | params->mem_test = 0; |
| 114 | params->mem_hot = 0; |
| 115 | params->mem_cold_max = cache->cache_size; // default to the cache size (fallback) |
| 116 | params->ht_test = create_hashtable(HASH_POWER_DEFAULT); |
| 117 | |
| 118 | ClockPro_parse_params(cache, DEFAULT_PARAMS); |
| 119 | if (cache_specific_params != NULL) { |
| 120 | ClockPro_parse_params(cache, cache_specific_params); |
| 121 | } |
| 122 | |
| 123 | return cache; |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * free resources used by this cache |
no test coverage detected