scheduler 1.4.0 → 1.4.1
raw patch · 3 files changed
+17/−2 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Control.Scheduler: replicateWork :: Applicative m => Int -> Scheduler m a -> m a -> m ()
Files
- CHANGELOG.md +4/−0
- scheduler.cabal +1/−1
- src/Control/Scheduler.hs +12/−1
CHANGELOG.md view
@@ -1,3 +1,7 @@+# 1.4.1++* Add functions: `replicateWork`+ # 1.4.0 * Worker id has been promoted from `Int` to a `newtype` wrapper `WorkerId`.
scheduler.cabal view
@@ -1,5 +1,5 @@ name: scheduler-version: 1.4.0+version: 1.4.1 synopsis: Work stealing scheduler. description: A work stealing scheduler that is primarly developed for [massiv](https://github.com/lehins/massiv) array librarry, but it is general enough to be useful for any computation that fits the model of few workers many jobs. homepage: https://github.com/lehins/haskell-scheduler
src/Control/Scheduler.hs view
@@ -30,6 +30,7 @@ , scheduleWorkId_ , scheduleWorkState , scheduleWorkState_+ , replicateWork , terminate , terminate_ , terminateWith@@ -233,7 +234,6 @@ terminateWith :: Scheduler m a -> a -> m a terminateWith = _terminateWith - -- | Schedule an action to be picked up and computed by a worker from a pool of -- jobs. Similar to `scheduleWorkId`, except the job doesn't get the worker id. --@@ -252,6 +252,17 @@ -- @since 1.2.0 scheduleWorkId_ :: Scheduler m () -> (WorkerId -> m ()) -> m () scheduleWorkId_ = _scheduleWorkId++-- | Schedule the same action to run @n@ times concurrently. This differs from+-- `replicateConcurrently` by allowing the caller to use the `Scheduler` freely,+-- or to allow early termination via `terminate` across all (identical) threads.+-- To be called within a `withScheduler` block.+--+-- @since 1.4.1+replicateWork :: Applicative m => Int -> Scheduler m a -> m a -> m ()+replicateWork !n scheduler f+ | n <= 0 = pure ()+ | otherwise = scheduleWork scheduler f *> replicateWork (pred n) scheduler f -- | Similar to `terminate`, but for a `Scheduler` that does not keep any results of computation. --