Commit 141f44cb authored by Francesco Zoffoli's avatar Francesco Zoffoli Committed by Facebook GitHub Bot

atomic_wait expects the old value, not the new one

Summary: The linked paper, the implementation and the tests use the parameter as the old value, but the parameter name is called `expected`.

Reviewed By: aary

Differential Revision: D25975108

fbshipit-source-id: bb67a95b057973e31512e9f972e1646e5a0f7d77
parent 65c55155
......@@ -51,16 +51,16 @@ extern ParkingLot<std::uint32_t> parkingLot;
template <template <typename...> class Atom, typename... Args>
void atomic_wait_impl(
const Atom<std::uint32_t, Args...>* atomic,
std::uint32_t expected) {
futexWait(atomic, expected);
std::uint32_t old) {
futexWait(atomic, old);
return;
}
template <template <typename...> class Atom, typename Integer, typename... Args>
void atomic_wait_impl(const Atom<Integer, Args...>* atomic, Integer expected) {
void atomic_wait_impl(const Atom<Integer, Args...>* atomic, Integer old) {
static_assert(!std::is_same<Integer, std::uint32_t>{}, "");
parkingLot.park(
atomic, -1, [&] { return atomic->load() == expected; }, [] {});
atomic, -1, [&] { return atomic->load() == old; }, [] {});
}
template <
......
......@@ -46,11 +46,11 @@ namespace folly {
*/
// mimic: std::atomic_wait, p1135r0
template <typename Integer>
void atomic_wait(const std::atomic<Integer>* atomic, Integer expected);
void atomic_wait(const std::atomic<Integer>* atomic, Integer old);
template <typename Integer, typename Clock, typename Duration>
std::cv_status atomic_wait_until(
const std::atomic<Integer>* atomic,
Integer expected,
Integer old,
const std::chrono::time_point<Clock, Duration>& deadline);
// mimic: std::atomic_notify_one, p1135r0
......
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