Tentative atomic_queue patch
This commit is contained in:
parent
c919cc9c90
commit
a31ded0797
1 changed files with 15 additions and 18 deletions
33
src/external/atomic_queue/atomic_queue.h
vendored
33
src/external/atomic_queue/atomic_queue.h
vendored
|
|
@ -95,27 +95,24 @@ constexpr T& map(T* elements, unsigned index) noexcept {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
constexpr T decrement(T x) { return x - 1; }
|
||||||
|
template<class T>
|
||||||
|
constexpr T increment(T x) { return x + 1; }
|
||||||
|
template<class T>
|
||||||
|
constexpr T or_equal(T x, unsigned u) { return (x | x >> u); }
|
||||||
|
template<class T, class... Args>
|
||||||
|
constexpr T or_equal(T x, unsigned u, Args... rest)
|
||||||
|
{
|
||||||
|
return or_equal(or_equal(x, u), rest...);
|
||||||
|
}
|
||||||
|
|
||||||
constexpr uint32_t round_up_to_power_of_2(uint32_t a) noexcept {
|
constexpr uint32_t round_up_to_power_of_2(uint32_t a) noexcept {
|
||||||
--a;
|
return increment(or_equal(decrement(a), 1, 2, 4, 8, 16));
|
||||||
a |= a >> 1;
|
|
||||||
a |= a >> 2;
|
|
||||||
a |= a >> 4;
|
|
||||||
a |= a >> 8;
|
|
||||||
a |= a >> 16;
|
|
||||||
++a;
|
|
||||||
return a;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr uint64_t round_up_to_power_of_2(uint64_t a) noexcept {
|
constexpr uint64_t round_up_to_power_of_2(uint64_t a) noexcept {
|
||||||
--a;
|
return increment(or_equal(decrement(a), 1, 2, 4, 8, 16, 32));
|
||||||
a |= a >> 1;
|
|
||||||
a |= a >> 2;
|
|
||||||
a |= a >> 4;
|
|
||||||
a |= a >> 8;
|
|
||||||
a |= a >> 16;
|
|
||||||
a |= a >> 32;
|
|
||||||
++a;
|
|
||||||
return a;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -304,7 +301,7 @@ public:
|
||||||
static_cast<Derived&>(*this).do_push(std::forward<T>(element), head);
|
static_cast<Derived&>(*this).do_push(std::forward<T>(element), head);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pop() noexcept {
|
Derived& pop() noexcept {
|
||||||
unsigned tail;
|
unsigned tail;
|
||||||
if(Derived::spsc_) {
|
if(Derived::spsc_) {
|
||||||
tail = tail_.load(X);
|
tail = tail_.load(X);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue