Debian Codegraph @

src/helper/pmon/processregistry.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/helper/pmon/processregistry.cpp`/
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #include "processregistry.h"cxx . . $ `<file>/src/helper/pmon/processregistry.h`/
5
6 #include "iappregistry.h"cxx . . $ `<file>/src/helper/pmon/iappregistry.h`/
7 #include <memory>
8 #include <utility>
9
10 class ProcessRegistrycxx . . $ ProcessRegistry#::AppRegistryObservercxx . . $ ProcessRegistry#AppRegistryObserver# : public IAppRegistrycxx . . $ IAppRegistry#::Observercxx . . $ IAppRegistry#Observer#
11 {
12 public:
13 AppRegistryObservercxx . . $ ProcessRegistry#AppRegistryObserver#AppRegistryObserver(9160a1e26a3cc228).(ProcessRegistrycxx . . $ ProcessRegistry# &outer) noexcept;
14 void registeredAppcxx . . $ ProcessRegistry#AppRegistryObserver#registeredApp(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &app) override;
15 void unregisteredAppcxx . . $ ProcessRegistry#AppRegistryObserver#unregisteredApp(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &app) override;
16
17 private:
18 ProcessRegistrycxx . . $ ProcessRegistry# &outer_cxx . . $ ProcessRegistry#AppRegistryObserver#outer_.;
19 };
20
21 ProcessRegistrycxx . . $ ProcessRegistry#::AppRegistryObservercxx . . $ ProcessRegistry#AppRegistryObserver#::AppRegistryObservercxx . . $ ProcessRegistry#AppRegistryObserver#AppRegistryObserver(9160a1e26a3cc228).(
22 ProcessRegistrycxx . . $ ProcessRegistry# &outer) noexcept
23 : outer_cxx . . $ ProcessRegistry#AppRegistryObserver#outer_.(outer)
24 {
25 }
26
27 void ProcessRegistrycxx . . $ ProcessRegistry#::AppRegistryObservercxx . . $ ProcessRegistry#AppRegistryObserver#::registeredAppcxx . . $ ProcessRegistry#AppRegistryObserver#registeredApp(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &app)
28 {
29 outer_cxx . . $ ProcessRegistry#AppRegistryObserver#outer_..registeredAppcxx . . $ ProcessRegistry#registeredApp(9c546c94e5fcce4e).(app);
30 }
31
32 void ProcessRegistrycxx . . $ ProcessRegistry#::AppRegistryObservercxx . . $ ProcessRegistry#AppRegistryObserver#::unregisteredAppcxx . . $ ProcessRegistry#AppRegistryObserver#unregisteredApp(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &app)
33 {
34 outer_cxx . . $ ProcessRegistry#AppRegistryObserver#outer_..unregisteredAppcxx . . $ ProcessRegistry#unregisteredApp(9c546c94e5fcce4e).(app);
35 }
36
37 ProcessRegistrycxx . . $ ProcessRegistry#::ProcessRegistrycxx . . $ ProcessRegistry#ProcessRegistry(f4d4064d3339a82d).(stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<IAppRegistrycxx . . $ IAppRegistry#> appRegistry) noexcept
38 : appRegObserver_cxx . . $ ProcessRegistry#appRegObserver_.(stdcxx . . $ std/::make_sharedcxx . . $ std/make_shared(25752750ef11e821).<ProcessRegistrycxx . . $ ProcessRegistry#::AppRegistryObservercxx . . $ ProcessRegistry#AppRegistryObserver#>(*this))
39 {
40 appRegistry->cxx . . $ std/__shared_ptr_access#`operator->`(34d6acfd341ba7ab).addObservercxx . . $ IAppRegistry#addObserver(2fb1f0ad00763439).(appRegObserver_cxx . . $ std/shared_ptr#shared_ptr(d70455e50ed85f60).);
41 }
42
43 void ProcessRegistrycxx . . $ ProcessRegistry#::addcxx . . $ ProcessRegistry#add(448e1223d74ef93).(int PID, stdcxx . . $ std/::stringcxx . . $ std/string# const &app)
44 {
45 stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(mutex_cxx . . $ ProcessRegistry#mutex_.);
46
47 auto const pidIt = pidReg_cxx . . $ ProcessRegistry#pidReg_..findcxx . . $ std/unordered_map#find(f711f2f81556fe93).(PID);
48 if (pidIt == pidReg_cxx . . $ ProcessRegistry#pidReg_..cendcxx . . $ std/unordered_map#cend(f3c6e12ee1fe7252).()) {
49 pidReg_cxx . . $ ProcessRegistry#pidReg_..insertcxx . . $ std/unordered_map#insert(e946fb78224671dd).({cxx . . $ std/pair#pair(62e1774a2dc03c82).PID, app});
50
51 // increment counter
52 auto const appIt = appCounterReg_cxx . . $ ProcessRegistry#appCounterReg_..findcxx . . $ std/unordered_map#find(f711f2f81556fe93).(app);
53 if (appIt != appCounterReg_cxx . . $ ProcessRegistry#appCounterReg_..cendcxx . . $ std/unordered_map#cend(f3c6e12ee1fe7252).())
54 ++appIt->cxx . . $ std/__detail/_Node_iterator#`operator->`(35610babf8706b50).secondcxx . . $ std/pair#second.;
55 }
56 }
57
58 void ProcessRegistrycxx . . $ ProcessRegistry#::removecxx . . $ ProcessRegistry#remove(d4f767463ce0a6b3).(int PID)
59 {
60
61 stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(mutex_cxx . . $ ProcessRegistry#mutex_.);
62
63 auto const pidIt = pidReg_cxx . . $ ProcessRegistry#pidReg_..findcxx . . $ std/unordered_map#find(f711f2f81556fe93).(PID);
64 if (pidIt != pidReg_cxx . . $ ProcessRegistry#pidReg_..cendcxx . . $ std/unordered_map#cend(f3c6e12ee1fe7252).()) {
65 auto const app = stdcxx . . $ std/__cxx11/basic_string#basic_string(8f3aaafa33d05d0b).::movecxx . . $ std/move(e35c19a1ba7baa26).(pidIt->cxx . . $ std/__detail/_Node_iterator#`operator->`(35610babf8706b50).secondcxx . . $ std/pair#second.);
66 pidReg_cxx . . $ ProcessRegistry#pidReg_..erasecxx . . $ std/unordered_map#erase(d465664efb4c2d93).(pidIt);
67
68 // decrement counter
69 auto appIt = appCounterReg_cxx . . $ ProcessRegistry#appCounterReg_..findcxx . . $ std/unordered_map#find(f711f2f81556fe93).(app);
70 if (appIt != appCounterReg_cxx . . $ ProcessRegistry#appCounterReg_..endcxx . . $ std/unordered_map#end(58ae48d364eea91c).())
71 --appIt->cxx . . $ std/__detail/_Node_iterator#`operator->`(35610babf8706b50).secondcxx . . $ std/pair#second.;
72 }
73 }
74
75 bool ProcessRegistrycxx . . $ ProcessRegistry#::runningcxx . . $ ProcessRegistry#running(7c222eea44a24d43).(stdcxx . . $ std/::stringcxx . . $ std/string# const &app)
76 {
77 stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(mutex_cxx . . $ ProcessRegistry#mutex_.);
78
79 auto const it = appCounterReg_cxx . . $ ProcessRegistry#appCounterReg_..findcxx . . $ std/unordered_map#find(f711f2f81556fe93).(app);
80 if (it != appCounterReg_cxx . . $ ProcessRegistry#appCounterReg_..cendcxx . . $ std/unordered_map#cend(f3c6e12ee1fe7252).())
81 return it->cxx . . $ std/__detail/_Node_iterator#`operator->`(35610babf8706b50).secondcxx . . $ std/pair#second. > 0;
82
83 return false;
84 }
85
86 stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::stringcxx . . $ std/string#> ProcessRegistrycxx . . $ ProcessRegistry#::findAppcxx . . $ ProcessRegistry#findApp(aeccc7d5c30f8eff).(int PID)
87 {
88 stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(mutex_cxx . . $ ProcessRegistry#mutex_.);
89
90 auto const it = pidReg_cxx . . $ ProcessRegistry#pidReg_..findcxx . . $ std/unordered_map#find(f711f2f81556fe93).(PID);
91 if (it != pidReg_cxx . . $ ProcessRegistry#pidReg_..endcxx . . $ std/unordered_map#end(58ae48d364eea91c).())
92 return itcxx . . $ std/optional#optional(e3f0d6382bd52f24).->cxx . . $ std/__detail/_Node_iterator#`operator->`(35610babf8706b50).secondcxx . . $ std/pair#second.;
93
94 return {cxx . . $ std/optional#optional(ced63f7c635d850d).};
95 }
96
97 void ProcessRegistrycxx . . $ ProcessRegistry#::registeredAppcxx . . $ ProcessRegistry#registeredApp(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &app)
98 {
99 stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(mutex_cxx . . $ ProcessRegistry#mutex_.);
100 appCounterReg_cxx . . $ ProcessRegistry#appCounterReg_..insertcxx . . $ std/unordered_map#insert(e946fb78224671dd).({cxx . . $ std/pair#pair(62e1774a2dc03c82).app, 0});
101 }
102
103 void ProcessRegistrycxx . . $ ProcessRegistry#::unregisteredAppcxx . . $ ProcessRegistry#unregisteredApp(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &app)
104 {
105 stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(mutex_cxx . . $ ProcessRegistry#mutex_.);
106
107 for (auto it = pidReg_cxx . . $ ProcessRegistry#pidReg_..begincxx . . $ std/unordered_map#begin(58ae48d364eea91c).(); it != pidReg_cxx . . $ ProcessRegistry#pidReg_..endcxx . . $ std/unordered_map#end(58ae48d364eea91c).();) {
108 if (it->cxx . . $ std/__detail/_Node_iterator#`operator->`(35610babf8706b50).secondcxx . . $ std/pair#second. ==cxx . . $ std/`operator==`(5ea818b58063a774). app)
109 it =cxx . . $ std/__detail/_Node_iterator#`operator=`(4ad824251779954e). pidReg_cxx . . $ ProcessRegistry#pidReg_..erasecxx . . $ std/unordered_map#erase(d465664efb4c2d93).(it);
110 else
111 ++cxx . . $ std/__detail/_Node_iterator#operator++(28297288f8fa886a).it;
112 }
113
114 appCounterReg_cxx . . $ ProcessRegistry#appCounterReg_..erasecxx . . $ std/unordered_map#erase(ff4e454bb663bf95).(app);
115 }