hal::mock::stall_detector detector(10ms);
// Do the actions that may cause a stall to occur like polling a register or waiting a duration of time.
detector.operation_finished();
The stall detector should spawn a thread that waits the amount of time specified in the constructor. That thread should throw an exception if the operation_finished() has not been called in the amount of time specified. That thrown exception object is not accessible by the rest of the code ensuring that it terminates the test. It would also be good to take a std::source_location as well in order for the developer to know where the deadlock occurred in the code. Maybe even a stack trace as well from the termination site. The destructor should join the thread.
It should look like this:
The stall detector should spawn a thread that waits the amount of time specified in the constructor. That thread should throw an exception if the
operation_finished()
has not been called in the amount of time specified. That thrown exception object is not accessible by the rest of the code ensuring that it terminates the test. It would also be good to take astd::source_location
as well in order for the developer to know where the deadlock occurred in the code. Maybe even a stack trace as well from the termination site. The destructor should join the thread.