Commit 24af36b0 authored by Sean Purcell's avatar Sean Purcell Committed by Facebook Github Bot

Fix specialization for atomic_notify_all

Summary:
The uint32_t futex specialization for atomic_notify_all didn't remove
the Integer template parameter, causing calls with atomic<uint32_t> to not
specialize properly.

Reviewed By: yfeldblum

Differential Revision: D14957311

fbshipit-source-id: 063e0f6d18360d7e2ce8dd5bbf5c46c52a6fc833
parent fa67b121
...@@ -104,7 +104,7 @@ void atomic_notify_one_impl(const Atom<Integer, Args...>* atomic) { ...@@ -104,7 +104,7 @@ void atomic_notify_one_impl(const Atom<Integer, Args...>* atomic) {
}); });
} }
template <template <typename...> class Atom, typename Integer, typename... Args> template <template <typename...> class Atom, typename... Args>
void atomic_notify_all_impl(const Atom<std::uint32_t, Args...>* atomic) { void atomic_notify_all_impl(const Atom<std::uint32_t, Args...>* atomic) {
futexWake(atomic); futexWake(atomic);
return; return;
......
...@@ -44,6 +44,29 @@ void run_atomic_wait_basic() { ...@@ -44,6 +44,29 @@ void run_atomic_wait_basic() {
one.join(); one.join();
} }
template <typename Integer>
void run_atomic_notify_all() {
auto&& atomic = std::atomic<Integer>{0};
auto&& func = [&]() {
while (true) {
atomic_wait(&atomic, Integer{0});
if (atomic.load() == 1) {
break;
}
}
};
auto&& t0 = std::thread{func};
auto&& t1 = std::thread{func};
atomic.store(1);
atomic_notify_all(&atomic);
t0.join();
t1.join();
}
template <typename Integer> template <typename Integer>
void run_atomic_wait_until_with_timeout() { void run_atomic_wait_until_with_timeout() {
auto&& atomic = std::atomic<Integer>{0}; auto&& atomic = std::atomic<Integer>{0};
...@@ -169,6 +192,16 @@ TEST(AtomicWait, BasicNonStandardWidths) { ...@@ -169,6 +192,16 @@ TEST(AtomicWait, BasicNonStandardWidths) {
run_atomic_wait_basic<std::uint64_t>(); run_atomic_wait_basic<std::uint64_t>();
} }
TEST(AtomicWait, AtomicNotifyAll) {
run_atomic_notify_all<std::uint32_t>();
}
TEST(AtomicWait, AtomicNotifyAllNonStandardWidths) {
run_atomic_notify_all<std::uint8_t>();
run_atomic_notify_all<std::uint16_t>();
run_atomic_notify_all<std::uint64_t>();
}
TEST(AtomicWait, AtomicWaitUntilTimeout) { TEST(AtomicWait, AtomicWaitUntilTimeout) {
run_atomic_wait_until_with_timeout<std::uint32_t>(); run_atomic_wait_until_with_timeout<std::uint32_t>();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment