Exemplo n.º 1
0
void truncate_stat_cache() {
  string path_to_delete;
  unsigned int hit_count = 0;
  unsigned int lowest_hit_count = 0;

  pthread_mutex_lock(&stat_cache_lock);
  stat_cache_t::iterator iter;
  for(iter = stat_cache.begin(); iter != stat_cache.end(); iter++) {
    hit_count = (* iter).second.hit_count;

    if(!lowest_hit_count)
      lowest_hit_count = hit_count;

    if(lowest_hit_count > hit_count)
      path_to_delete = (* iter).first;
  }

  stat_cache.erase(path_to_delete);
  pthread_mutex_unlock(&stat_cache_lock);

  cout << "    purged " << path_to_delete << " from the stat cache" << endl;
}