@@ -15,64 +15,6 @@ namespace Plugin {
1515
1616SERVICE_REGISTRATION (Launcher, 1 , 0 );
1717
18- class MemoryObserverImpl : public Exchange ::IMemory {
19- private:
20- MemoryObserverImpl ();
21- MemoryObserverImpl (const MemoryObserverImpl&);
22- MemoryObserverImpl& operator =(const MemoryObserverImpl&);
23-
24- public:
25- MemoryObserverImpl (const uint32_t id)
26- : _main(id == 0 ? Core::ProcessInfo().Id() : id)
27- , _observable(false )
28- {
29- }
30- ~MemoryObserverImpl ()
31- {
32- }
33-
34- public:
35- virtual void Observe (const uint32_t pid)
36- {
37- if (pid == 0 ) {
38- _observable = false ;
39- }
40- else {
41- _main = Core::ProcessInfo (pid);
42- _observable = true ;
43- }
44- }
45- virtual uint64_t Resident () const
46- {
47- return (_observable == false ? 0 : _main.Resident ());
48- }
49- virtual uint64_t Allocated () const
50- {
51- return (_observable == false ? 0 : _main.Allocated ());
52- }
53- virtual uint64_t Shared () const
54- {
55- return (_observable == false ? 0 : _main.Shared ());
56- }
57- virtual uint8_t Processes () const
58- {
59- return (IsOperational () ? 1 : 0 );
60- }
61- virtual const bool IsOperational () const
62- {
63- return (_observable == false ) || (_main.IsActive ());
64- }
65-
66- BEGIN_INTERFACE_MAP (MemoryObserverImpl)
67- INTERFACE_ENTRY (Exchange::IMemory)
68- END_INTERFACE_MAP
69-
70- private:
71- Core::ProcessInfo _main;
72- bool _observable;
73- };
74-
75-
7618/* static */ Launcher::ProcessObserver Launcher::_observer;
7719
7820/* virtual */ const string Launcher::Initialize (PluginHost::IShell* service)
@@ -106,7 +48,10 @@ SERVICE_REGISTRATION(Launcher, 1, 0);
10648 }
10749 }
10850
109- _activity = Core::ProxyType<Job>::Create (&config, interval);
51+ _memory = Core::Service<MemoryObserverImpl>::Create<Exchange::IMemory>(0 );
52+ ASSERT (_memory != nullptr );
53+
54+ _activity = Core::ProxyType<Job>::Create (&config, interval, _memory);
11055 if (_activity.IsValid () == true ) {
11156 if (_activity->IsOperational () == false ) {
11257 // Well if we where able to parse the parameters (if needed) we are ready to start it..
@@ -136,15 +81,24 @@ SERVICE_REGISTRATION(Launcher, 1, 0);
13681 else {
13782 PluginHost::WorkerPool::Instance ().Submit (_activity);
13883 }
84+
13985 }
14086 else {
87+ _activity.Release ();
14188 message = _T (" Could not parse the configuration for the job." );
14289 }
14390 }
14491 else {
14592 message = _T (" Could not create the job." );
14693 }
14794
95+ if (_activity.IsValid () == false ) {
96+ if (_memory != nullptr ) {
97+ _memory->Release ();
98+ _memory = nullptr ;
99+ }
100+ }
101+
148102 return (message);
149103}
150104
@@ -153,6 +107,8 @@ SERVICE_REGISTRATION(Launcher, 1, 0);
153107 ASSERT (_service == service);
154108 ASSERT (_memory != nullptr );
155109
110+ PluginHost::WorkerPool::Instance ().Revoke (_activity);
111+
156112 _observer.Unregister (&_notification);
157113
158114 if (_memory != nullptr ) {
@@ -188,7 +144,8 @@ void Launcher::Update(const ProcessObserver::Info& info)
188144 ASSERT (_service != nullptr );
189145
190146 if (info.Event () == ProcessObserver::Info::EVENT_EXIT) {
191-
147+
148+ _memory->Observe (0 );
192149 if ((info.ExitCode () & 0xFFFF ) == 0 ) {
193150 // Only do this if we do not need a retrigger on an intervall.
194151 if (_activity->IsOperational () == false ) {
0 commit comments