inline void lru_cache_cab::insert(const bucket* pbuck, const double & time) { assert(cache.size() + flow_table.size() <=_capacity); buffer_check.insert(std::make_pair(pbuck, time)); // insert bucket as rec cache.insert(container_T::value_type(pbuck, time)); // insert bucket for (auto iter = pbuck->related_rules.begin(); iter != pbuck->related_rules.end(); iter++) { // rule_down_count += 1; // controller does not know which rules are kept in OFswtich auto ins_rule_result = flow_table.insert(std::make_pair(*iter, 1)); if (!ins_rule_result.second) ++ins_rule_result.first->second; else ++rule_down_count; // controller knows which rules are kept in OFswitch } while(cache.size() + flow_table.size() > _capacity) // kick out { const bucket * to_kick_buck = cache.right.begin()->second; cache.right.erase(cache.right.begin()); buffer_check.erase(to_kick_buck); for (auto iter = to_kick_buck->related_rules.begin(); iter != to_kick_buck->related_rules.end(); ++iter) // dec flow occupy no. { --flow_table[*iter]; if (flow_table[*iter] == 0) flow_table.erase(*iter); } } }
__inline__ typename container_T::size_type size() const { boost::mutex::scoped_lock lock(mmutex); return mqueue.size(); }
typename hash_T::digest_type compute_digest_data(container_T const &c) { return compute_digest_n<hash_T>(c.data(), c.size()); }