Skip to content

Commit 793be94

Browse files
committed
comments
1 parent a15f0cd commit 793be94

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ghcide/src/Development/IDE/Core/ProgressReporting.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,15 @@ noProgressReporting = return $ ProgressReporting
4747
, inProgress = const id
4848
, progressStop = pure ()
4949
}
50+
51+
-- | State used in 'delayedProgressReporting'
5052
data State
5153
= NotStarted
5254
| Completed
5355
| Stopped
5456
| Running (Async ())
5557

58+
-- | State transitions used in 'delayedProgressReporting'
5659
data Transition = Event ProgressEvent | StopProgress
5760

5861
updateState :: IO () -> Transition -> State -> IO State
@@ -65,7 +68,12 @@ updateState _ (Event KickCompleted) st = pure st
6568
updateState _ StopProgress (Running a) = cancel a $> Stopped
6669
updateState _ StopProgress st = pure st
6770

68-
data InProgress = InProgress {todo, done :: !Int, current :: !(HMap.HashMap NormalizedFilePath Int)}
71+
-- | Data structure to track progress across the project
72+
data InProgress = InProgress
73+
{ todo :: !Int -- ^ Number of files to do
74+
, done :: !Int -- ^ Number of files done
75+
, current :: !(HMap.HashMap NormalizedFilePath Int)
76+
}
6977

7078
recordProgress :: NormalizedFilePath -> (Int -> Int) -> InProgress -> InProgress
7179
recordProgress file shift InProgress{..} = case HMap.alterF alter file current of
@@ -79,7 +87,6 @@ recordProgress file shift InProgress{..} = case HMap.alterF alter file current o
7987
-- | A 'ProgressReporting' that enqueues Begin and End notifications in a new
8088
-- thread, with a grace period (nothing will be sent if 'KickCompleted' arrives
8189
-- before the end of the grace period).
82-
-- Avoid using in tests where progress notifications are used to assert invariants.
8390
delayedProgressReporting
8491
:: Seconds -- ^ Grace period before starting
8592
-> Seconds -- ^ sampling delay

0 commit comments

Comments
 (0)