Closed elfenpiff closed 3 years ago
An idea to simplify the timer would be to not spawn a new thread for each timer invocation, since this makes it really messy and introduces unnecessary complexity. Instead of SIGEV_THREAD for our sigevent we could probably use SIGEV_THREAD_ID on linux and SIGEV_SIGNAL_THREAD or SIGEV_PULSE on QNX. The callback would be executed after a blocking wait with sigwait or sigwaitinfo on a thread spawned by the user. I wouldn't recommend to let the timer spawn the thread, since this makes it less flexible. This should massively reduce the complexity of the current implementation. I need to dig deeper into this to confirm if we could fully reimplement the timer with those sigevents.
Decision was to remove the posix::Timer
completely and then start from scratch if there is the necessity for a timer.
Required information
At the moment the timer uses multiple atomics, mutexes etc. to ensure that there is no race condition which would skip a callback or call it multiple times. The current implementation is too complex and we have no hard stress tests to make sure such race conditions do not exist anymore.
Hence, we have to refactor the timer so that it is based only on iceoryx_utils concurrent structures which are well tested. This would reduce the imminent risk of further race conditions or other concurrent misbehaviors massively.