orc 1.2.1.2 → 1.2.1.3
raw patch · 4 files changed
+44/−25 lines, 4 filesdep ~deepseqdep ~mtl
Dependency ranges changed: deepseq, mtl
Files
- orc.cabal +16/−7
- src/Control/Concurrent/Hierarchical.hs +24/−14
- src/Orc/Combinators.hs +2/−2
- src/Orc/Monad.hs +2/−2
orc.cabal view
@@ -1,5 +1,5 @@ name: orc-version: 1.2.1.2+version: 1.2.1.3 synopsis: Orchestration-style co-ordination EDSL description: Provides an EDSL with Orc primitives. category: Web@@ -8,16 +8,16 @@ author: John Launchbury, Trevor Elliott maintainer: John Launchbury, Trevor Elliott Copyright: (c) 2008-2010, Galois, Inc.-cabal-version: >= 1.2.0+cabal-version: >= 1.10 build-type: Simple Library- Extensions: GeneralizedNewtypeDeriving+ Default-language: Haskell2010 Build-Depends: base >= 4.2.0.0 && < 5.0, stm >= 2.2.0.0 && < 2.5, process >= 1.0.1.0 && < 1.2,- mtl >= 2.0.1.0 && < 2.1,+ mtl >= 2.0.1.0, monadIO >= 0.10.1.1 && < 0.11, deepseq >= 1.1.0.0 && < 1.4 Exposed-modules: Control.Concurrent.Hierarchical@@ -26,11 +26,20 @@ Orc Hs-Source-Dirs: src Ghc-Options: -Wall+ if (impl(ghc >= 7))+ CPP-Options: -D__GHC_BLOCK_DEPRECATED__ Executable orc- Extensions: GeneralizedNewtypeDeriving+ Default-language: Haskell2010 main-is: test.hs- Build-Depends: deepseq,+ Build-Depends: base >= 4.2.0.0 && < 5.0,+ stm >= 2.2.0.0 && < 2.5,+ process >= 1.0.1.0 && < 1.2,+ mtl >= 2.0.1.0,+ monadIO >= 0.10.1.1 && < 0.11,+ deepseq >= 1.1.0.0 && < 1.4, random hs-source-dirs: src src/Examples- ghc-options: -threaded+ Ghc-Options: -threaded+ if (impl(ghc >= 7))+ CPP-Options: -D__GHC_BLOCK_DEPRECATED__
src/Control/Concurrent/Hierarchical.hs view
@@ -12,6 +12,7 @@ -- when they are killed. {-# OPTIONS_GHC -fno-warn-unused-do-bind #-}+{-# LANGUAGE CPP #-} module Control.Concurrent.Hierarchical (@@ -21,12 +22,12 @@ , runHIO -- :: HIO b -> IO b , newPrimGroup , newGroup -- :: HIO Group- + , local , close , Group , finished- + ) where import Control.Monad@@ -67,7 +68,7 @@ --------------------------------------------------------------------------- -- ^ The thread-registry environment is a hierarchical structure of local--- thread neighborhoods. +-- thread neighborhoods. -- | A thread 'Group' keeps tracks of its inhabitants, which may be -- threads or other 'Group's.@@ -81,14 +82,23 @@ instance HasFork HIO where- fork hio = HIO $ \w -> block $ do+#ifdef __GHC_BLOCK_DEPRECATED__+ fork hio = HIO $ \w -> mask $ \ restore -> do when countingThreads incrementThreadCount increment w+ fork (do tid <- myThreadId+ register (Thread tid) w+ restore (hio `inGroup` w)+ `finally`+ decrement w)+#else+ fork hio = HIO $ \w -> block $ do fork (block (do tid <- myThreadId register (Thread tid) w unblock (hio `inGroup` w))- `finally` - decrement w)+ `finally`+ decrement w)+#endif -- | Creates a new thread group and registers the current environment's@@ -123,7 +133,7 @@ runHIO :: HIO b -> IO () runHIO hio = do w <- newPrimGroup- r <- hio `inGroup` w+ _r <- hio `inGroup` w isZero w when countingThreads printThreadReport return ()@@ -165,18 +175,18 @@ --------------------------------------------------------------------------- -- Profiling code: Records how many threads were created -countingThreads :: Bool +countingThreads :: Bool countingThreads = False -- set to enable reporting or not -threadCount :: TVar Integer -threadCount = unsafePerformIO $ newTVar 0 +threadCount :: TVar Integer+threadCount = unsafePerformIO $ newTVar 0 incrementThreadCount :: IO ()-incrementThreadCount = modifyTVar_ threadCount (+1) +incrementThreadCount = modifyTVar_ threadCount (+1) printThreadReport :: IO () printThreadReport = do- n <- readTVar threadCount - putStrLn "----------------------------" - putStrLn (show n ++ " HIO threads were forked") + n <- readTVar threadCount+ putStrLn "----------------------------"+ putStrLn (show n ++ " HIO threads were forked")
src/Orc/Combinators.hs view
@@ -100,7 +100,7 @@ --------------------------------------------------------------------------- -- | Wait for a period of w seconds, then continue processing.-delay :: (RealFrac a) => a -> Orc ()+delay :: (RealFrac a, Show a) => a -> Orc () delay w = (liftIO $ threadDelay (round (w * 1000000))) <|> (silent $ do guard (w>100)@@ -137,7 +137,7 @@ scan f s p = do accum <- newTVar s x <- p- (w,w') <- modifyTVar accum (f x)+ (_w,w') <- modifyTVar accum (f x) return w' -- | A variant of '<+>', pronounced or-else, which performs and returns
src/Orc/Monad.hs view
@@ -95,7 +95,7 @@ runOrc p = runHIO (p # \_ -> return ()) instance Applicative Orc where- pure = return+ pure = return f <*> x = ap f x instance MonadPlus Orc where@@ -147,7 +147,7 @@ -- | An alternate mechanism for 'eagerly', it fires up a thread for @p@ -- and returns a lazy thunk that contains the single (trimmed) result--- of the computation. Be careful to use this function with 'public'+-- of the computation. Be careful to use this function with 'publish' -- when these lazy values need to be fully evaluated before proceeding -- further. For example, the following code succeeds immediately: --