doTick: use exception-safe modifyMVar_ instead of takeMVar/putMVar #1100
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #1099, maybe.
disclaimer: i dont fully understand the logic of manipulating
stateMV
indoTick
(and the other locations that touch this MVar)... at the beginning the value is taken out, and if everything runs successfully, a new value is put in. the exception handler doesnt touchstateMV
, so it seems like any exception should leave it empty. yet i dont see the hang with all mini-notation syntax errors - for example, Tidal recovers just fine fromd1 $ n "<0 1 2§>*16" # s "808"
. not sure how.but i am making a guess that the intent here is not to leave
stateMV
empty on error. to this end, i replaced thetakeMVar
/putMVar
sequence with amodifyMVar_
. from my testing so far, this seems to resolve the issue, but im not sure if there might be some undesired side effects.(i also moved the exception handler into its own function, as i found the previous parenthesized multi-line blocks difficult to read, but let me know if that style is preferred)