The Wayback Machine - https://web.archive.org/web/20210112001417/https://github.com/cpp-netlib/cpp-netlib/pull/893
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clear_resolved_cache implementation #893

Open
wants to merge 2 commits into
base: master
from
Open

Conversation

@gns333
Copy link

@gns333 gns333 commented Dec 25, 2020

basic_client_facade write a clear_resolved_cache() but no functions are implemented with pimpl. Add implementation for async_resolver and sync_resolver.

gns333 added 2 commits Dec 25, 2020
@@ -36,18 +36,21 @@ struct async_resolver : std::enable_shared_from_this<async_resolver<Tag> > {
typedef std::function<void(resolver_type &, string_type, std::uint16_t,
resolve_completion_function)> resolve_function;

void clear_resolved_cache() { clear_cache_ = true; }

This comment has been minimized.

@deanberris

deanberris Jan 11, 2021
Member

You probably want to make clear_cache_ an std::atomic<bool> so that it's thread-safe to modify it from different threads.

if (clear_cache_) {
clear_cache_ = false;
endpoint_cache_.clear();
}

This comment has been minimized.

@deanberris

deanberris Jan 11, 2021
Member

This will have to change if you use an std::atomic<bool> to reset the value to false. Something like:

if (clear_cache_.exchange(false)) {
  endpoint_cache_.clear()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.