Make lf_queue<> compatible with atomic_wait

This commit is contained in:
Nekotekina 2020-12-15 18:06:51 +03:00
parent ca5f0444bf
commit e39348ad96
4 changed files with 39 additions and 4 deletions

View file

@ -307,14 +307,25 @@ public:
delete m_head.load();
}
void wait() noexcept
template <atomic_wait::op Flags = atomic_wait::op::eq>
void wait(std::nullptr_t null = nullptr) noexcept
{
if (m_head == nullptr)
{
m_head.wait(nullptr);
m_head.template wait<Flags>(nullptr);
}
}
const volatile void* observe() const noexcept
{
return m_head.load();
}
explicit operator bool() const noexcept
{
return m_head != nullptr;
}
template <typename... Args>
void push(Args&&... args)
{
@ -414,6 +425,18 @@ public:
}
};
namespace atomic_wait
{
template <typename T>
inline __m128i default_mask<lf_queue<T>> = _mm_cvtsi64_si128(-1);
template <typename T>
constexpr __m128i get_value(lf_queue<T>&, std::nullptr_t value = nullptr)
{
return _mm_setzero_si128();
}
}
// Concurrent linked list, elements remain until destroyed.
template <typename T>
class lf_bunch final