X-Git-Url: http://gitweb.michael.orlitzky.com/?p=haeredes.git;a=blobdiff_plain;f=src%2FMain.hs;h=679a1ac1fe1d0dc3cf684420596676dde91e10e5;hp=a5dc79466067f0dc70fc529169f55d111ae13b96;hb=71c5a7f6c3a8ecb4c17f454e0e27a21538379f58;hpb=689bda2499ec821772b456cb7982527d6740649f diff --git a/src/Main.hs b/src/Main.hs index a5dc794..679a1ac 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -2,7 +2,7 @@ module Main where import Control.Concurrent.ParallelIO.Global ( - parallel, + parallelInterleaved, stopGlobalPool ) import Control.Monad (unless) import qualified Data.ByteString.Char8 as BS ( @@ -113,10 +113,17 @@ main = do NS{} -> lookupNS' MX{} -> lookupMX' - _ <- withResolver rs $ \resolver -> do - -- Bad stuff happens if we try to run these lookups in parallel - -- instead of the reports. - records <- mapM (lookup_function resolver) nrml_domains - parallel (map (report nrml_delegates) records) + let lookup' d = withResolver rs $ \resolver -> + lookup_function resolver d + + -- Construct a list of [IO whatever]. The withResolver calls + -- are the ones that should be run in parallel. + let actions = map lookup' nrml_domains + + -- Run the lookup actions in parallel. + results <- parallelInterleaved actions + + -- Output the results. + _ <- mapM (report nrml_delegates) results stopGlobalPool