diff --git a/emper/Fiber.hpp b/emper/Fiber.hpp index b49b941c98de3bca966e60bdb321bdb6a873f24c..81806b2359f9423522a461c9a42fd0b64f7ad250 100644 --- a/emper/Fiber.hpp +++ b/emper/Fiber.hpp @@ -84,6 +84,14 @@ private: } inline bool setRunnableFalse() { + bool res = runnable.load(std::memory_order_relaxed); + if (!res) { + // Fast path: 'runnable' was already set to false. No need + // for an atomic operation. + // Mesure: Impact of this "optimization". Is it really one? + return res; + } + return runnable.exchange(false); }