@@ -5,6 +5,7 @@
55module Network.Wai.Handler.Warp.Timeout (
66 Manager
77 , Handle
8+ , TimeoutAction
89 , initialize
910 , stopManager
1011 , register
@@ -39,10 +40,11 @@ import System.Mem.Weak (deRefWeak)
3940-- | A timeout manager
4041newtype Manager = Manager (IORef [Handle])
4142
43+-- | An action to be performed on timeout.
44+type TimeoutAction = IO ()
45+
4246-- | A handle used by 'Manager'
43−--
44−-- First field is action to be performed on timeout.
45−data Handle = Handle (IO ()) (IORef State)
47+data Handle = Handle TimeoutAction (IORef State)
4648
4749data State = Active -- Manager turns it to Inactive.
4850 | Inactive -- Manager removes it with timeout action.
@@ -102,7 +104,7 @@ ignoreAll _ = return ()
102104----------------------------------------------------------------
103105
104106-- | Registering a timeout action.
105−register :: Manager -> IO () -> IO Handle
107+register :: Manager -> TimeoutAction -> IO Handle
106108register (Manager ref) onTimeout = do
107109 iactive <- I.newIORef Active
108110 let h = Handle onTimeout iactive