Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add an unload action to close the state

  • Loading branch information...
commit 4b2918f964edd0e5f25063b83687a73e226b98f9 1 parent d06eefb
@mightybyte authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/Snap/Snaplet/AcidState.hs
View
5 src/Snap/Snaplet/AcidState.hs
@@ -71,6 +71,7 @@ acidInit' :: A.IsAcidic st
-> SnapletInit b (Acid st)
acidInit' location initial = makeSnaplet "acid-state" description Nothing $ do
st <- liftIO $ A.openLocalStateFrom location initial
+ onUnload (A.closeAcidState st)
return $ Acid st
@@ -136,7 +137,9 @@ createCheckpoint = do
------------------------------------------------------------------------------
-- | Wrapper for acid-state's closeAcidState function that works for
--- arbitrary instances of HasAcid.
+-- arbitrary instances of HasAcid. The state is automatically closed by the
+-- snaplet's unload action, but this is here in case the user needs more
+-- control.
closeAcidState = do
st <- getAcidState
liftIO $ A.closeAcidState st
Please sign in to comment.
Something went wrong with that request. Please try again.