Skip to content

Commit

Permalink
removing the tricky code.
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Nov 19, 2024
1 parent af20093 commit a385430
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions auto-update/Control/Reaper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,22 @@ reaper settings@ReaperSettings{..} stateRef tidRef = do
!merge <- reaperAction wl
-- Merging the left jobs and new jobs.
-- If there is no jobs, this thread finishes.
next <- atomicModifyIORef' stateRef (check merge)
next
cont <- atomicModifyIORef' stateRef (check merge)
if cont
then
reaper settings stateRef tidRef
else
writeIORef tidRef Nothing
where
swapWithEmpty NoReaper = error "Control.Reaper.reaper: unexpected NoReaper (1)"
swapWithEmpty (Workload wl) = (Workload reaperEmpty, wl)

check _ NoReaper = error "Control.Reaper.reaper: unexpected NoReaper (2)"
check merge (Workload wl)
-- If there is no job, reaper is terminated.
| reaperNull wl' = (NoReaper, writeIORef tidRef Nothing)
| reaperNull wl' = (NoReaper, False)
-- If there are jobs, carry them out.
| otherwise = (Workload wl', reaper settings stateRef tidRef)
| otherwise = (Workload wl', True)
where
wl' = merge wl

Expand Down

0 comments on commit a385430

Please sign in to comment.