on master help sign in
stopping using join.

Probably this is not necessary. But I want to ensure proper tail calls.

commit6c36bf1711612311c3a91be4a93caccdddcc6266 authorKazu Yamamoto <kazu@iij.ad.jp> dateWed 16 Dec 2015, 11:13 (11 years ago) parentb9a6b32
1 file changed+6−3
auto-update/Control/Reaper.hs+6−3
auto-update/Control/Reaper.hs+6−3
@@ -24,7 +24,7 @@ module Control.Reaper (
2424import Control.AutoUpdate.Util (atomicModifyIORef')
2525import Control.Concurrent (forkIO, threadDelay)
2626import Control.Exception (mask_)
27−import Control.Monad (join, void)
27+import Control.Monad (void)
2828import Data.IORef (IORef, newIORef, readIORef)
2929
3030-- | Settings for creating a reaper. This type has two parameters:
@@ -129,7 +129,9 @@ mkReaper settings@ReaperSettings{..} = do
129129add :: ReaperSettings workload item -> IORef (State workload) -> item
130130 -> IO ()
131131add settings@ReaperSettings{..} stateRef item =
132− mask_ $ join $ atomicModifyIORef' stateRef cons
132+ mask_ $ do
133+ next <- atomicModifyIORef' stateRef cons
134+ next
133135 where
134136 cons NoReaper = (Workload $ reaperCons item reaperEmpty
135137 ,spawn settings stateRef)
@@ -149,7 +151,8 @@ reaper settings@ReaperSettings{..} stateRef = do
149151 merge <- reaperAction wl
150152 -- Merging the left jobs and new jobs.
151153 -- If there is no jobs, this thread finishes.
152− join $ atomicModifyIORef' stateRef (check merge)
154+ next <- atomicModifyIORef' stateRef (check merge)
155+ next
153156 where
154157 swapWithEmpty NoReaper = error "Control.Reaper.reaper: unexpected NoReaper (1)"
155158 swapWithEmpty (Workload wl) = (Workload reaperEmpty, wl)