[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36

John Goerzen jgoerzen at complete.org
Fri Apr 23 15:11:43 UTC 2010


The following commit has been merged in the master branch:
commit a2cc83a9bbb3aafcd406d177451e423d833e7f53
Author: John Goerzen <jgoerzen at complete.org>
Date:   Tue Oct 10 22:38:05 2006 +0100

    Checkpointing

diff --git a/MissingH/ProgressTracker.hs b/MissingH/ProgressTracker.hs
index d9a639f..64e7df4 100644
--- a/MissingH/ProgressTracker.hs
+++ b/MissingH/ProgressTracker.hs
@@ -39,6 +39,11 @@ module MissingH.ProgressTracker (-- * Types
                                  -- * Creation
                                  newProgress, newProgress',
                                  -- * Updating
+                                 incrP, incrP',
+                                 -- * Reading and Processing
+                                 getSpeed,
+                                 getETR,
+                                 getETA,
                                  -- * Utilities
                                  defaultTimeSource
                                )
@@ -130,11 +135,30 @@ newProgress' news newts newcb =
 -- Updating
 ----------------------------------------------------------------------
 {- | Increment the completed unit count in the 'Progress' object
-by the amount given. -}
+by the amount given.  If the value as given exceeds the total, then
+the total will also be raised to match this value so that the 
+completed count never exceeds the total.
+
+You can decrease the completed unit count by supplying a negative number
+here. -}
 incrP :: Progress -> Integer -> IO ()
-incrP po count = 
+-- FIXME: handle parents/callbacks
+incrP po count = modStatus po statusfunc
+    where statusfunc s = 
+             s {completedUnits = newcu s,
+                totalUnits = if newcu s > totalUnits s
+                                 then newcu s
+                                 else totalUnits s}
+          newcu s = completedUnits s + count                  
+
+{- | Like 'incrP', but never modify the total. -}
+incrP' :: Progress -> Integer -> IO ()
+-- FIXME: handle parents/callbacks
+incrP' po count = 
     modStatus po (\s -> s {completedUnits = completedUnits s + count})
 
+
+
 ----------------------------------------------------------------------
 -- Utilities
 ----------------------------------------------------------------------

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list