From 3b8c7328861b462967c483a2ea9965d1c0d9fef1 Mon Sep 17 00:00:00 2001
From: Florian Fischer <florian.fischer@muhq.space>
Date: Fri, 13 May 2022 15:55:16 +0200
Subject: [PATCH] IoSleepStrategies: increment notifications stats in the
 AbstractIoSleepStrategy

The WaitfdSleepStrategy did not gather the amount of posted notifications
but the PipeSleepStrategy did.
Move the stats accounting into AbstractIoSleepStrategy so all derived
strategies track the amount of written notifications.
---
 emper/sleep_strategy/AbstractIoSleepStrategy.hpp | 1 +
 emper/sleep_strategy/PipeSleepStrategy.hpp       | 3 ---
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/emper/sleep_strategy/AbstractIoSleepStrategy.hpp b/emper/sleep_strategy/AbstractIoSleepStrategy.hpp
index bab7e299..7118c8c9 100644
--- a/emper/sleep_strategy/AbstractIoSleepStrategy.hpp
+++ b/emper/sleep_strategy/AbstractIoSleepStrategy.hpp
@@ -271,6 +271,7 @@ class AbstractIoSleepStrategy : public Logger<LogSubsystem::SLEEP_S> {
 		const unsigned toWakeup = getSleeperCountToWakeup<callerEnvironment>(sleeping, count);
 		if (toWakeup) {
 			stats.incNotify();
+			stats.addNotifications(toWakeup);
 			if constexpr (callerEnvironment == CallerEnvironment::EMPER) {
 				writeNotificationsFromEmper(hint, toWakeup);
 			} else {
diff --git a/emper/sleep_strategy/PipeSleepStrategy.hpp b/emper/sleep_strategy/PipeSleepStrategy.hpp
index 96c1e98c..c1ab8c4f 100644
--- a/emper/sleep_strategy/PipeSleepStrategy.hpp
+++ b/emper/sleep_strategy/PipeSleepStrategy.hpp
@@ -14,7 +14,6 @@
 #include "emper-common.h"
 #include "sleep_strategy/AbstractIoSleepStrategy.hpp"
 #include "sleep_strategy/AbstractWorkerSleepStrategy.hpp"
-#include "sleep_strategy/Stats.hpp"
 
 class Runtime;
 
@@ -47,8 +46,6 @@ class PipeSleepStrategy : public AbstractWorkerSleepStrategy<PipeSleepStrategy>,
 	Pipe global;
 
 	void writeNotifications(emper::FiberHint hint, unsigned count) {
-		stats.addNotifications(count);
-
 		std::vector<void*> hints(count, hint);
 
 		ssize_t res = write(global.notifyFd, hints.data(), sizeof(void*) * hints.size());
-- 
GitLab