IP_Address IP::resolve_hostname(const String &p_hostname, IP::Type p_type) { GLOBAL_LOCK_FUNCTION; String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type); if (resolver->cache.has(key)) return resolver->cache[key]; IP_Address res = _resolve_hostname(p_hostname, p_type); resolver->cache[key] = res; return res; }
IP_Address IP::resolve_hostname(const String &p_hostname, IP::Type p_type) { resolver->mutex->lock(); String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type); if (resolver->cache.has(key)) { IP_Address res = resolver->cache[key]; resolver->mutex->unlock(); return res; } IP_Address res = _resolve_hostname(p_hostname, p_type); resolver->cache[key] = res; resolver->mutex->unlock(); return res; }
} HashMap<String, IP_Address> cache; }; IP_Address IP::resolve_hostname(const String& p_hostname) { GLOBAL_LOCK_FUNCTION if (resolver->cache.has(p_hostname)) return resolver->cache[p_hostname]; IP_Address res = _resolve_hostname(p_hostname); resolver->cache[p_hostname]=res; return res; } IP::ResolverID IP::resolve_hostname_queue_item(const String& p_hostname) { GLOBAL_LOCK_FUNCTION ResolverID id = resolver->find_empty_id(); if (id==RESOLVER_INVALID_ID) { WARN_PRINT("Out of resolver queries"); return id; }