Skip to content

Commit df51767

Browse files
committed
Moved job to thread pool
1 parent 452533e commit df51767

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CMakeCache.txt
2+
CMakeFiles
23
Launcher.json
34
Makefile
45
cmake_install.cmake

Launcher.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ class Launcher : public PluginHost::IPlugin {
535535
};
536536

537537
public:
538-
class Job: public Core::IDispatch {
538+
class Job {
539539
private:
540540
typedef std::vector<uint32_t> ProcessList;
541541

@@ -554,6 +554,7 @@ class Launcher : public PluginHost::IPlugin {
554554
, _shutdownPhase(0)
555555
, _processListEmpty(1, 1)
556556
, _shutdownCompleted(false)
557+
, _job(*this)
557558
{
558559
auto iter = config->Parameters.Elements();
559560

@@ -572,8 +573,9 @@ class Launcher : public PluginHost::IPlugin {
572573
}
573574
_memory->AddRef();
574575
}
575-
~Job() override
576+
~Job()
576577
{
578+
_job.Revoke();
577579
_memory->Release();
578580
}
579581

@@ -629,18 +631,18 @@ class Launcher : public PluginHost::IPlugin {
629631
}
630632
void Schedule (const Core::Time& time) {
631633
if (time <= Core::Time::Now()) {
632-
PluginHost::WorkerPool::Instance().Submit(Core::ProxyType<Core::IDispatch>(*this));
634+
_job.Submit();
633635
}
634636
else {
635-
PluginHost::WorkerPool::Instance().Schedule(time, Core::ProxyType<Core::IDispatch>(*this));
637+
_job.Reschedule(time);
636638
}
637639
}
638640
void Shutdown () {
639641
_adminLock.Lock();
640642
_shutdownPhase = 1;
641643
_adminLock.Unlock();
642644

643-
PluginHost::WorkerPool::Instance().Revoke(Core::ProxyType<Core::IDispatch>(*this));
645+
_job.Revoke();
644646
if (_process.IsActive() == true) {
645647

646648
// First try a gentle touch....
@@ -677,11 +679,10 @@ class Launcher : public PluginHost::IPlugin {
677679
}
678680

679681
private:
680-
string Identifier() const override {
681-
return (_T("Launcher::Command(\"") + _options.Command() + _T("\")"));
682-
}
683-
void Dispatch() override
682+
friend Core::ThreadPool::JobType<Job&>;
683+
void Dispatch()
684684
{
685+
TRACE(Trace::Information, (_T("Launcher: job is dispatched")));
685686
// Let limit the jitter on the next run, if required..
686687
Core::Time nextRun (Core::Time::Now());
687688

@@ -704,7 +705,7 @@ class Launcher : public PluginHost::IPlugin {
704705
if (_shutdownPhase == 0) {
705706
// Reschedule our next launch point...
706707
nextRun.Add(_interval.TimeInSeconds() * Time::MilliSecondsPerSecond);
707-
PluginHost::WorkerPool::Instance().Schedule(nextRun, Core::ProxyType<Core::IDispatch>(*this));
708+
_job.Reschedule(nextRun);
708709
}
709710
_adminLock.Unlock();
710711
}
@@ -721,6 +722,8 @@ class Launcher : public PluginHost::IPlugin {
721722
ProcessList _processList;
722723
Core::Event _processListEmpty;
723724
Core::BinairySemaphore _shutdownCompleted;
725+
726+
Core::WorkerPool::JobType<Job&> _job;
724727
};
725728

726729
public:

0 commit comments

Comments
 (0)