Esempio n. 1
0
void deserialize(Deserializer& source, cache<Key, Value, Policy>& c) {
  uint64_t size, capacity;
  source >> capacity >> size;
  c.capacity(capacity);
  Key k;
  Value v;
  for (uint64_t i = 0; i < size; ++i) {
    source >> k >> v;
    c.insert(std::move(k), std::move(v));
  }
}
Esempio n. 2
0
 // return true if n contains a variable in the range [begin, end]
 bool operator()(expr * n, unsigned begin = 0, unsigned end = UINT_MAX) {
     m_contains   = false;
     m_window     = end - begin;
     m_todo.reset();
     m_cache.reset();
     m_todo.push_back(expr_delta_pair(n, begin));
     while (!m_todo.empty()) {
         expr_delta_pair e = m_todo.back();
         if (visit_children(e.m_node, e.m_delta)) {
             m_cache.insert(e);
             m_todo.pop_back();
         }
         if (m_contains) {
             return true;
         }
     }
     SASSERT(!m_contains);
     return false;
 }
Esempio n. 3
0
int aggr_source_discovery::add_to_cache(cache &c, int ifindex,
					const inet6_addr &group,
					const inet6_addr &src) {
	sg_pair p(group, src);

	cache::iterator i = c.find(p);

	time_t now = time(0);

	if (i == c.end()) {
		c.insert(std::make_pair(p, now));

		if (g_mrd->should_log(INTERNAL_FLOW)) {
			g_mrd->log().xprintf("AggrSourceDiscovery added source"
					     " (%{Addr}, %{Addr}) to cache.\n",
					     src, group);
		}

		return 1;
	} else {
		if ((now - i->second) > m_keepalive) {
			if (g_mrd->should_log(INTERNAL_FLOW)) {
				g_mrd->log().xprintf("AggrSourceDiscovery "
						     "updated source (%{Addr},"
						     "%{Addr}), cache was old.\n",
						     src, group);
			}

			/* was in the cache but is old */
			source_discovery_origin::discovered_source(ifindex, group, src);

			return 0;
		}

		i->second = now;
	}

	return -1;
}
Esempio n. 4
0
 expr save_result(expr const & e, expr && r) {
     m_cache.insert(std::make_pair(e, r));
     return r;
 }