From: Yedidya Feldblum Date: Wed, 10 Jan 2018 06:39:13 +0000 (-0800) Subject: Futex::futexWait returns FutexResult X-Git-Tag: v2018.01.15.00~24 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=e229101b0e2fc1d9ccfbcb10be991cb62e19d32d;hp=8bfee85eb0e54a346a8c2fe1ac8b474303b754b0 Futex::futexWait returns FutexResult Summary: [Folly] `Futex::futexWait` returns `FutexResult`. Reviewed By: nbronson Differential Revision: D6673871 fbshipit-source-id: 378c69d8362970e985da31e31d8e9b0179d2917f --- diff --git a/folly/detail/Futex.h b/folly/detail/Futex.h index 1e72b15c..000bf1a6 100644 --- a/folly/detail/Futex.h +++ b/folly/detail/Futex.h @@ -52,10 +52,10 @@ struct Futex : Atom, boost::noncopyable { /** Puts the thread to sleep if this->load() == expected. Returns true when * it is returning because it has consumed a wake() event, false for any * other return (signal, this->load() != expected, or spurious wakeup). */ - bool futexWait(uint32_t expected, uint32_t waitMask = -1) { + FutexResult futexWait(uint32_t expected, uint32_t waitMask = -1) { auto rv = futexWaitImpl(expected, nullptr, nullptr, waitMask); assert(rv != FutexResult::TIMEDOUT); - return rv == FutexResult::AWOKEN; + return rv; } /** Similar to futexWait but also accepts a deadline until when the wait call diff --git a/folly/detail/MemoryIdler.h b/folly/detail/MemoryIdler.h index 3c987cc9..caac253e 100644 --- a/folly/detail/MemoryIdler.h +++ b/folly/detail/MemoryIdler.h @@ -102,7 +102,7 @@ struct MemoryIdler { template < template class Atom, typename Clock = std::chrono::steady_clock> - static bool futexWait( + static FutexResult futexWait( Futex& fut, uint32_t expected, uint32_t waitMask = -1, @@ -110,7 +110,6 @@ struct MemoryIdler { defaultIdleTimeout.load(std::memory_order_acquire), size_t stackToRetain = kDefaultStackToRetain, float timeoutVariationFrac = 0.5) { - if (idleTimeout == Clock::duration::max()) { // no need to use futexWaitUntil if no timeout is possible return fut.futexWait(expected, waitMask); @@ -128,7 +127,7 @@ struct MemoryIdler { // finished before timeout hit, no flush assert(rv == FutexResult::VALUE_CHANGED || rv == FutexResult::AWOKEN || rv == FutexResult::INTERRUPTED); - return rv == FutexResult::AWOKEN; + return rv; } } diff --git a/folly/test/FutexTest.cpp b/folly/test/FutexTest.cpp index 464c8524..7da35b71 100644 --- a/folly/test/FutexTest.cpp +++ b/folly/test/FutexTest.cpp @@ -39,14 +39,14 @@ typedef DeterministicSchedule DSched; template