[gnome-system-monitor] Revert "After 35d69c72, std::map<pid_t, ProcInfo> requires ProcInfo to be"
- From: Benoît Dejean <bdejean src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-monitor] Revert "After 35d69c72, std::map<pid_t, ProcInfo> requires ProcInfo to be"
- Date: Mon, 26 Jun 2017 11:42:35 +0000 (UTC)
commit c7ead6f7ea29ef0e4e063789a06c62b84fd0f54f
Author: Benoît Dejean <bdejean gmail com>
Date: Mon Jun 26 13:31:23 2017 +0200
Revert "After 35d69c72, std::map<pid_t, ProcInfo> requires ProcInfo to be"
This reverts commit f876154239d2ac92381c40cf5ed1e68362000717.
src/application.h | 22 ++++------------------
src/proctable.cpp | 2 +-
2 files changed, 5 insertions(+), 19 deletions(-)
---
diff --git a/src/application.h b/src/application.h
index d66c26f..3190298 100644
--- a/src/application.h
+++ b/src/application.h
@@ -152,33 +152,19 @@ class ProcList {
// sorted by pid. The map has a nice property : it is sorted
// by pid so this helps a lot when looking for the parent node
// as ppid is nearly always < pid.
- typedef std::map<pid_t, std::shared_ptr<ProcInfo>> List;
+ typedef std::map<pid_t, ProcInfo> List;
List data;
std::mutex data_lock;
public:
std::map<pid_t, unsigned long> cpu_times;
-
- struct Iterator
- {
- typedef List::iterator It;
- typedef std::pair<pid_t, ProcInfo&> value_type;
- It it;
- std::shared_ptr<value_type> value;
-
- Iterator(const It& it) : it(it) {}
- bool operator!=(const Iterator& other) const { return it != other.it; }
- Iterator& operator++() { ++it; return *this; }
- value_type* operator->() { value = std::make_shared<value_type>(it->first, *it->second); return
value.get(); }
- value_type& operator*() { value = std::make_shared<value_type>(it->first, *it->second); return
*value.get(); }
- };
-
+ typedef List::iterator Iterator;
Iterator begin() { return std::begin(data); }
Iterator end() { return std::end(data); }
Iterator erase(Iterator it) {
std::lock_guard<std::mutex> lg(data_lock);
- return data.erase(it.it);
+ return data.erase(it);
}
- ProcInfo* add(pid_t pid) { return data.emplace(pid,
std::make_shared<ProcInfo>(pid)).first->second.get(); }
+ ProcInfo* add(pid_t pid) { return &data.emplace(pid, pid).first->second; }
void clear() { return data.clear(); }
ProcInfo* find(pid_t pid);
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 23b3e3b..384e55f 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -66,7 +66,7 @@
ProcInfo* ProcList::find(pid_t pid)
{
auto it = data.find(pid);
- return (it == data.end() ? nullptr : it->second.get());
+ return (it == data.end() ? nullptr : &it->second);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]