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 fallback implementation for waitable atomics #6293
Conversation
{ | ||
// Initialize node from a dummy container (there is no separate node constructor) | ||
std::multimap<const void*, waiter> dummy; | ||
return dummy.extract(dummy.emplace(nullptr, &s_tls_waiter)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be a long shot, but won't constructing via an initializer list work? Or would that be relying on an implementation detail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no usable autonomous constructors for nodes in standard (except default and move).
{ | ||
auto& wmap = get_fallback_map(data); | ||
|
||
std::lock_guard lock(wmap.mutex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is shared_mutex
(essentially a read/write lock) available on this platform? It'd allow concurrent access on wmap.list
for reading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be available on all C++17 compatible platforms, but it's not usable with std::condition_variable, and the map is modified upon notification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::condition_variable_any
may meet the requirements for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you can see that its implementation typically has a pair of std::mutex and std::condition_variable (which are only optimized to be interoperable).
May improve perf on OSX/BSD
May improve perf on OSX/BSD