Skip to content

Commit

Permalink
Simplify thread resuming (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickKa authored Aug 9, 2023
2 parents a17c66f + 8612062 commit 6059338
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 34 deletions.
18 changes: 3 additions & 15 deletions Sts1CobcSw/EduCommunicationErrorThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,9 @@ class EduCommunicationErrorThread : public RODOS::StaticThread<stackSize>
}
} eduCommunicationErrorThread;


// TODO: Think about whether this is the right way to declare, design, use, etc. this
class ResumeEduErrorCommunicationThread : public RODOS::TimeEvent
{
public:
auto handle() -> void override
{
eduCommunicationErrorThread.resume();
RODOS::PRINTF("[EduCommunicationErrorThread] EduCommunicationThread resumed\n");
}
} resumeEduErrorCommunicationThread;


auto ResumeEduErrorCommunicationThread() -> void
auto ResumeEduCommunicationErrorThread() -> void
{
resumeEduErrorCommunicationThread.handle();
eduCommunicationErrorThread.resume();
RODOS::PRINTF("[EduCommunicationErrorThread] EduCommunicationErrorThread resumed\n");
}
}
2 changes: 1 addition & 1 deletion Sts1CobcSw/EduCommunicationErrorThread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ namespace sts1cobcsw
extern std::int32_t eduCommunicationErrorCounter;


auto ResumeEduErrorCommunicationThread() -> void;
auto ResumeEduCommunicationErrorThread() -> void;
}
4 changes: 2 additions & 2 deletions Sts1CobcSw/EduListenerThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class EduListenerThread : public StaticThread<>
// RODOS::PRINTF(
// "[EduListenerThread] Edu communication error after call to
// GetStatus().\n");
ResumeEduErrorCommunicationThread();
ResumeEduCommunicationErrorThread();
}
else
{
Expand Down Expand Up @@ -117,7 +117,7 @@ class EduListenerThread : public StaticThread<>
"[EduListenerThread] Communication error after call to "
"ReturnResult().\n");
*/
ResumeEduErrorCommunicationThread();
ResumeEduCommunicationErrorThread();
}
else
{
Expand Down
20 changes: 4 additions & 16 deletions Sts1CobcSw/EduProgramQueueThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class EduProgramQueueThread : public RODOS::StaticThread<stackSize>
RODOS::PRINTF("UpdateTime error code : %d\n", errorCode);
RODOS::PRINTF(
"[EduProgramQueueThread] Communication error after call to UpdateTime().\n");
ResumeEduErrorCommunicationThread();
ResumeEduCommunicationErrorThread();
}

auto startDelay2 = ComputeStartDelay();
Expand Down Expand Up @@ -143,7 +143,7 @@ class EduProgramQueueThread : public RODOS::StaticThread<stackSize>
RODOS::PRINTF(
"[EduProgramQueueThread] Communication error after call to "
"ExecuteProgram().\n");
ResumeEduErrorCommunicationThread();
ResumeEduCommunicationErrorThread();
}
else
{
Expand Down Expand Up @@ -179,21 +179,9 @@ auto ComputeStartDelay() -> std::int64_t
return startDelay;
}


// TODO: Think about whether this is the right way to declare, design, use, etc. this
class ResumeEduProgramQueueThreadEvent : public RODOS::TimeEvent
{
public:
auto handle() -> void override
{
eduProgramQueueThread.resume();
RODOS::PRINTF("EduProgramQueueThread resumed from me\n");
}
} resumeEduProgramQueueThreadEvent;


auto ResumeEduProgramQueueThread() -> void
{
resumeEduProgramQueueThreadEvent.handle();
eduProgramQueueThread.resume();
RODOS::PRINTF("[EduProgramQueueThread] EduProgramQueueThread resumed\n");
}
}

0 comments on commit 6059338

Please sign in to comment.