Skip to content
Snippets Groups Projects
Commit 884b9563 authored by Florian Schmaus's avatar Florian Schmaus
Browse files

Merge branch 'fix-PipeSleepStrategy-destructor' into 'master'

[PipeSleepStrategy] use C++ smart ptrs instead of manual memory management

See merge request i4/manycore/emper!220
parents 29736cf9 b7f93c8c
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@
#include <cassert> // for assert
#include <cerrno> // for errno, ECANCELED, EBUSY, EAGAIN, EINTR
#include <cstring> // for memset
#include <memory>
#include <ostream> // for basic_osteram::operator<<, operator<<
#include <string>
#include <utility>
......
......@@ -9,6 +9,7 @@
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <type_traits>
#include <vector>
......@@ -131,7 +132,7 @@ class PipeSleepStrategy : AbstractWorkerSleepStrategy<PipeSleepStrategy>,
std::atomic<size_t> wakeupDueToNotify = 0;
};
Stats* stats;
std::unique_ptr<Stats> stats;
workerid_t workerCount;
int sleepFd;
......@@ -253,12 +254,10 @@ class PipeSleepStrategy : AbstractWorkerSleepStrategy<PipeSleepStrategy>,
notifyFd = fds[1];
if constexpr (emper::STATS) {
stats = new Stats();
stats = std::make_unique<Stats>();
}
}
~PipeSleepStrategy() { delete stats; }
void printStats() { std::cout << *stats; }
[[nodiscard]] inline auto getSleeping() const -> long { return sleepers.load(); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment