@@ -473,6 +473,32 @@ spliceExpresions Splices{..} =
473
473
, DL. fromList $ map fst awSplices
474
474
]
475
475
476
+ -- | In addition to indexing the `.hie` file, this function is reponsible for
477
+ -- maintaining the IndexQueue state and notfiying the user about indexing
478
+ -- progress.
479
+ --
480
+ -- We maintain a record of all pending index operations in theh 'indexPending'
481
+ -- TVar When 'indexHieFile' is called, it must check to ensure that the file
482
+ -- hasn't already be queued up for indexing. If it has, then we can just skip it
483
+ --
484
+ -- Otherwise, we record the current file as pending and write an indexing
485
+ -- operation to the queue
486
+ --
487
+ -- When the indexing operation is picked up and executed by the worker thread,
488
+ -- the first thing it does is ensure that a newer index for the same file
489
+ -- hasn't been scheduled by looking at 'indexPending' If a newer index has been
490
+ -- scheduled, we can safely skip this one
491
+ --
492
+ -- Otherwise, we start or continue a progress reporting session, telling it
493
+ -- about progress so far and the current file we are attempting to index. Then
494
+ -- we can go ahead and call in to hiedb to actually do the indexing operation
495
+ --
496
+ -- Once this completes, we have to update the IndexQueue state First, we
497
+ -- must remove the just indexed file from 'indexPending' Then we check if
498
+ -- 'indexPending' is now empty. In that case, we end the progress session and
499
+ -- report the total number of file indexed. We also set the 'indexCompleted'
500
+ -- TVar to 0 in order to set it up for a fresh indexing session. Otherwise, we
501
+ -- can just increment the 'indexCompleted' TVar and exit.
476
502
indexHieFile :: ShakeExtras -> ModSummary -> NormalizedFilePath -> Fingerprint -> Compat. HieFile -> IO ()
477
503
indexHieFile se mod_summary srcPath hash hf = atomically $ do
478
504
pending <- readTVar indexPending
0 commit comments