Skip to content

Commit b4967c7

Browse files
committed
Added restart() process method
1 parent d583320 commit b4967c7

4 files changed

Lines changed: 31 additions & 0 deletions

File tree

src/ProcessScheduler/Process.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
return _scheduler.add(*this, enableIfNot);
4444
}
4545

46+
bool Process::restart()
47+
{
48+
return _scheduler.restart(*this);
49+
}
50+
4651

4752
bool Process::needsServicing(uint32_t start)
4853
{

src/ProcessScheduler/Process.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Process
2020
bool disable();
2121
bool enable();
2222
bool destroy();
23+
bool restart();
2324

2425
///////////////////// GETTERS /////////////////////////
2526
inline Scheduler &scheduler() { return _scheduler; }

src/ProcessScheduler/Scheduler.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ bool Scheduler::destroy(Process &process)
9898
return op.queue(_queue);
9999
}
100100

101+
102+
bool Scheduler::restart(Process &process)
103+
{
104+
QueableOperation op(&process, QueableOperation::RESTART_SERVICE);
105+
return op.queue(_queue);
106+
}
107+
101108
bool Scheduler::halt()
102109
{
103110
QueableOperation op(QueableOperation::HALT);
@@ -238,6 +245,17 @@ void Scheduler::procDestroy(Process &process)
238245
}
239246

240247

248+
void Scheduler::procRestart(Process &process)
249+
{
250+
if (isNotDestroyed(process)) {
251+
procDisable(process);
252+
process.cleanup();
253+
}
254+
process.setup();
255+
procEnable(process);
256+
}
257+
258+
241259
void Scheduler::procAdd(Process &process)
242260
{
243261
if (!isNotDestroyed(process)) {
@@ -324,6 +342,10 @@ void Scheduler::processQueue()
324342
procDestroy(*op.getProcess());
325343
break;
326344

345+
case QueableOperation::RESTART_SERVICE:
346+
procRestart(*op.getProcess());
347+
break;
348+
327349
case QueableOperation::HALT:
328350
procHalt();
329351
break;

src/ProcessScheduler/Scheduler.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Scheduler
1919
bool disable(Process &process);
2020
bool enable(Process &process);
2121
bool destroy(Process &process);
22+
bool restart(Process &process);
2223
bool halt();
2324

2425
uint8_t getID(Process &process);
@@ -45,6 +46,7 @@ class Scheduler
4546
DESTROY_SERVICE,
4647
DISABLE_SERVICE,
4748
ENABLE_SERVICE,
49+
RESTART_SERVICE,
4850
HALT,
4951
#ifdef _PROCESS_STATISTICS
5052
UPDATE_STATS,
@@ -69,6 +71,7 @@ class Scheduler
6971
void procEnable(Process &process);
7072
void procDestroy(Process &process);
7173
void procAdd(Process &process);
74+
void procRestart(Process &process);
7275
void procHalt();
7376

7477
void processQueue();

0 commit comments

Comments
 (0)