From 65ee020cec39db6d1dc723b19c70f694aa62c1b6 Mon Sep 17 00:00:00 2001 From: Florian Schmaus <flow@cs.fau.de> Date: Thu, 12 Jul 2018 16:11:24 +0200 Subject: [PATCH] Add fast path to Fiber.setRunnableFalse() --- emper/Fiber.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/emper/Fiber.hpp b/emper/Fiber.hpp index b49b941c..81806b23 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); } -- GitLab