Allow TimerTask to be safely restarted after shutdown and avoid duplicate tasks#1001
Conversation
a5e0f8f to
f3d097c
Compare
|
I have several concerns about the implementation of |
|
Yeah, I think I agree there are some semantic questions here. Particularly given the explicitly documented "run-then-sleep-N loop" implementation (as opposed to "run every N"), I think it's reasonable to expect that only one instance of the block will be running at any given time. (Notwithstanding the internal use of the The linked issues are clearly violations of that principle, and this PR reduces the circumstances where that can happen... but an Setting aside whether it's a complete fix, in terms of whether this PR is safe in isolation: I'm not certain of the semantics of an unsynchronized read of an instance variable that's potentially being written by another (synchronized) thread. Without going back to research it properly, the local implementation of On implementation, I note that ScheduledTask has a potentially-relevant |
1908a6e to
263feda
Compare
|
I force-pushed over the change, but In consultation with @matthewd, I I'm now using an AtomicFixnum to store and check the "age" of the TimerTask (incremented when started/restaretd) to try to avoid any variable reassignment. |
263feda to
af983a1
Compare
|
Is this ready to be merged, if so @bensheldon could you merge it? |
af983a1 to
d118f81
Compare
Fixes #672 and #662.
Creates a new @running object on shutdown while the ScheduledTask is checking the previously set @running object which will remain false.
Note: I don't like my testing strategy but couldn't think of a better one.