on master help sign in
Cleanup
commit1b3911b3394b3a90f54988d3ee372b42f5b01e91 authornanonaren <nano.naren@gmx.com> dateThu 5 May 2016, 18:41 (10 years ago) parent60fbb46
1 file changed+10−7
auto-update/Control/AutoUpdate.hs+10−7
auto-update/Control/AutoUpdate.hs+10−7
@@ -6,12 +6,12 @@
66-- second, and write the current time to a shared 'IORef', than it is for each
77-- request to make its own call to 'getCurrentTime'.
88--
9−-- But for a low-volume server, whose request frequency is less than once per
10−-- second, that approach will result in /more/ calls to 'getCurrentTime' than
9+-- But for a low-volume server, whose request frequency is less than once per
10+-- second, that approach will result in /more/ calls to 'getCurrentTime' than
1111-- necessary, and worse, kills idle GC.
1212--
1313-- This library solves that problem by allowing you to define actions which will
14−-- either be performed by a dedicated thread, or, in times of low volume, will
14+-- either be performed by a dedicated thread, or, in times of low volume, will
1515-- be executed by the calling thread.
1616--
1717-- Example usage:
@@ -98,16 +98,19 @@ data UpdateSettings a = UpdateSettings
9898 -- @since 0.1.0
9999 }
100100
101+-- | Generate an action which will either read from an automatically
102+-- updated value, or run the update action in the current thread.
103+--
104+-- @since 0.1.0
101105mkAutoUpdate :: UpdateSettings a -> IO (IO a)
102106mkAutoUpdate us = mkAutoUpdateHelper us Nothing
103107
108+-- | Generate an action which will either read from an automatically
109+-- updated value, or run the update action in the current thread if
110+-- the first time or the provided modify action after that.
104111mkAutoUpdateWithModify :: UpdateSettings a -> (a -> IO a) -> IO (IO a)
105112mkAutoUpdateWithModify us f = mkAutoUpdateHelper us (Just f)
106113
107−-- | Generate an action which will either read from an automatically
108−-- updated value, or run the update action in the current thread.
109−--
110−-- @since 0.1.0
111114mkAutoUpdateHelper :: UpdateSettings a -> Maybe (a -> IO a) -> IO (IO a)
112115mkAutoUpdateHelper us updateActionModify = do
113116 -- A baton to tell the worker thread to generate a new value.