Fix timer state after event queue was destroyed

* Hw tests show state is unaffected by external destruction of the event queue

* Minor race regarding state check fixed (can result in an undestroyable state)
This commit is contained in:
eladash 2019-03-26 21:08:49 +02:00 committed by Ivan
parent 90490f775d
commit 3c0564c9b7

View file

@ -1,4 +1,4 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/vm.h" #include "Emu/Memory/vm.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/IdManager.h" #include "Emu/IdManager.h"
@ -33,6 +33,7 @@ void lv2_timer_context::operator()()
if (const auto queue = port.lock()) if (const auto queue = port.lock())
{ {
queue->send(source, data1, data2, next); queue->send(source, data1, data2, next);
}
if (period) if (period)
{ {
@ -40,10 +41,9 @@ void lv2_timer_context::operator()()
expire += period; expire += period;
continue; continue;
} }
}
// Stop: oneshot or the event port was disconnected (TODO: is it correct?) // Stop after oneshot
state = SYS_TIMER_STATE_STOP; state.compare_and_swap_test(SYS_TIMER_STATE_RUN, SYS_TIMER_STATE_STOP);
continue; continue;
} }