@@ -14,16 +14,16 @@ module Development.IDE.Graph.Database(
1414 shakeShutDatabase ,
1515 shakeGetActionQueueLength ,
1616 shakeComputeToPreserve ,
17- shakedatabaseRuntimeDep ,
17+ -- shakedatabaseRuntimeDep,
1818 shakePeekAsyncsDelivers ,
19- upSweepAction ) where
19+ upSweepAction ,
20+ shakeGetTransitiveDirtyListBottomUp ) where
2021import Control.Concurrent.Async (Async )
2122import Control.Concurrent.STM.Stats (atomically ,
2223 readTVarIO )
2324import Control.Exception (SomeException )
24- import Control.Monad (forM , join )
25+ import Control.Monad (join )
2526import Data.Dynamic
26- import Data.HashMap.Strict (toList )
2727import Data.Maybe
2828import Data.Set (Set )
2929import Debug.Trace (traceEvent )
@@ -79,7 +79,7 @@ shakeRunDatabaseForKeysSep
7979 -> [Action a ]
8080 -> IO (IO [Either SomeException a ])
8181shakeRunDatabaseForKeysSep keysChanged (ShakeDatabase lenAs1 as1 db) as2 = do
82- traceEvent (" upsweep dirties " ++ show keysChanged) $ incDatabase db keysChanged
82+ bottomUp <- traceEvent (" upsweep dirties " ++ show keysChanged) $ incDatabase db keysChanged
8383 -- Prepare upsweep actions for changed keys if provided
8484 ups <- case keysChanged of
8585 Nothing -> pure []
@@ -91,39 +91,16 @@ shakeRunDatabaseForKeysSep keysChanged (ShakeDatabase lenAs1 as1 db) as2 = do
9191 -- as2Delayed <- mapM (mkDelayedActionI "user" 1) as2
9292 return $ drop lenAs1 <$> runActions (newKey " root" ) db (map unvoid (as1 ++ ups) ++ as2)
9393
94- -- shakeRunDatabaseForDelayedActionsSep
95- -- :: Maybe [Key]
96- -- -- ^ Set of keys changed since last run. 'Nothing' means everything has changed
97- -- -> ShakeDatabase
98- -- -> [Action a]
99- -- -> [(Key, Async ())]
100- -- -> Maybe KeySet
101- -- -> KeySet
102- -- -> IO (IO [Either SomeException a])
103- -- shakeRunDatabaseForDelayedActionsSep keysChanged (ShakeDatabase _lenAs1 as1 db) as2 preservedKeys affected newDirtyKeys = do
104- -- incDatabase db keysChanged
105- -- -- todo run as2 too
106- -- let preservedKeyset = fromListKeySet $ map fst preservedKeys
107- -- das1 = filter (\da -> shouldRun $ actionName da) as1
108- -- lenAs1 = length das1
109- -- shouldRun k = case (keysChanged, affected) of
110- -- (Nothing, _) -> k `notMemberKeySet` preservedKeyset
111- -- (Just _, Just afs) -> k `memberKeySet` afs
112- -- (Just _, Nothing) -> True
113- -- Step s <- readTVarIO (databaseStep db)
114- -- -- we don't know the child that triggered; use a self-child to kick the chain
115- -- ups <- mapM (\k -> mkDelayedActionFixed ("upsweep-" ++ show k) 1 (upSweepAction (Step s) k k)) (toListKeySet newDirtyKeys)
116- -- return $ drop lenAs1 <$> runActions db (map unvoid (das1 ++ ups) ++ filter (\da -> actionName da `notMemberKeySet` preservedKeyset) as2 )
117-
118- shakedatabaseRuntimeDep :: ShakeDatabase -> IO [(Key , KeySet )]
119- shakedatabaseRuntimeDep (ShakeDatabase _ _ db) =
120- atomically $ toList <$> computeReverseRuntimeMap db
121-
12294
12395shakeComputeToPreserve :: ShakeDatabase -> KeySet -> IO ([(Key , Async () )], KeySet )
12496shakeComputeToPreserve (ShakeDatabase _ _ db) ks = atomically (computeToPreserve db ks)
12597
126- -- a dsfds
98+ -- | Compute the transitive closure of the given keys over reverse dependencies
99+ -- and return them in bottom-up order (children before parents).
100+ shakeGetTransitiveDirtyListBottomUp :: ShakeDatabase -> [Key ] -> IO [Key ]
101+ shakeGetTransitiveDirtyListBottomUp (ShakeDatabase _ _ db) seeds =
102+ transitiveDirtyListBottomUp db seeds
103+
127104-- fds make it possible to do al ot of jobs
128105shakeRunDatabaseForKeys
129106 :: Maybe [Key ]
0 commit comments