auto-update 0.1.4 → 0.1.4.1
raw patch · 3 files changed
+22/−12 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +9/−0
- Control/Reaper.hs +12/−11
- auto-update.cabal +1/−1
ChangeLog.md view
@@ -1,3 +1,12 @@+# ChangeLog for auto-update++## 0.1.4.1++* [#693](https://github.com/yesodweb/wai/pull/693):+ Improve documentation for `reaperAction` function.+* [#732](https://github.com/yesodweb/wai/pull/732):+ Fixed memory leak in `reaperAdd` function.+ ## 0.1.4 * Provide updateActionModify API in AutoUpdate [#547](https://github.com/yesodweb/wai/pull/547)
Control/Reaper.hs view
@@ -5,7 +5,7 @@ -- threads. These threads will automatically spawn and die based on the -- presence of a workload to process on. Example uses include: ----- * Killing long-running jobs +-- * Killing long-running jobs -- * Closing unused connections in a connection pool -- * Pruning a cache of old items (see example below) --@@ -49,8 +49,9 @@ -- ^ The action to perform on a workload. The result of this is a -- \"workload modifying\" function. In the common case of using lists, -- the result should be a difference list that prepends the remaining- -- workload to the temporary workload. For help with setting up such- -- an action, see 'mkListAction'.+ -- workload to the temporary workload. The temporary workload here+ -- refers to items added to the workload while the reaper action is+ -- running. For help with setting up such an action, see 'mkListAction'. -- -- Default: do nothing with the workload, and then prepend it to the -- temporary workload. This is incredibly useless; you should@@ -112,7 +113,7 @@ -- | State of reaper. data State workload = NoReaper -- ^ No reaper thread- | Workload workload -- ^ The current jobs+ | Workload !workload -- ^ The current jobs -- | Create a reaper addition function. This function can be used to add -- new items to the workload. Spawning of reaper threads will be handled@@ -153,7 +154,7 @@ next <- atomicModifyIORef' stateRef cons next where- cons NoReaper = let !wl = reaperCons item reaperEmpty+ cons NoReaper = let wl = reaperCons item reaperEmpty in (Workload wl, spawn settings stateRef tidRef) cons (Workload wl) = let wl' = reaperCons item wl in (Workload wl', return ())@@ -214,16 +215,16 @@ go front' xs -- $example1--- In this example code, we use a 'Data.Map.Strict.Map' to cache fibonacci numbers, and a 'Reaper' to prune the cache. +-- In this example code, we use a 'Data.Map.Strict.Map' to cache fibonacci numbers, and a 'Reaper' to prune the cache. ----- The @main@ function first creates a 'Reaper', with fields to initialize the +-- The @main@ function first creates a 'Reaper', with fields to initialize the -- cache ('reaperEmpty'), add items to it ('reaperCons'), and prune it ('reaperAction').--- The reaper will run every two seconds ('reaperDelay'), but will stop running while +-- The reaper will run every two seconds ('reaperDelay'), but will stop running while -- 'reaperNull' is true. ----- @main@ then loops infinitely ('Control.Monad.forever'). Each second it calculates the fibonacci number --- for a value between 30 and 34, first trying the cache ('reaperRead' and 'Data.Map.Strict.lookup'), --- then falling back to manually calculating it (@fib@) +-- @main@ then loops infinitely ('Control.Monad.forever'). Each second it calculates the fibonacci number+-- for a value between 30 and 34, first trying the cache ('reaperRead' and 'Data.Map.Strict.lookup'),+-- then falling back to manually calculating it (@fib@) -- and updating the cache with the result ('reaperAdd') -- -- @clean@ simply removes items cached for more than 10 seconds.
auto-update.cabal view
@@ -1,5 +1,5 @@ name: auto-update-version: 0.1.4+version: 0.1.4.1 synopsis: Efficiently run periodic, on-demand actions description: API docs and the README are available at <http://www.stackage.org/package/auto-update>. homepage: https://github.com/yesodweb/wai