From: Michael Orlitzky Date: Sat, 5 Oct 2013 23:06:57 +0000 (-0400) Subject: Fix parallelization and bump to v0.3.0. X-Git-Tag: 0.3.0^0 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=71c5a7f6c3a8ecb4c17f454e0e27a21538379f58;p=haeredes.git Fix parallelization and bump to v0.3.0. --- diff --git a/haeredes.cabal b/haeredes.cabal index f008f76..e171258 100644 --- a/haeredes.cabal +++ b/haeredes.cabal @@ -1,5 +1,5 @@ name: haeredes -version: 0.2.0 +version: 0.3.0 cabal-version: >= 1.8 author: Michael Orlitzky maintainer: Michael Orlitzky 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