packages feed

concurrentoutput 0.2 → 0.2.0.1

raw patch · 2 files changed

+35/−20 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Test.hs view
@@ -1,18 +1,35 @@ import System.Terminal.Concurrent+import Control.Exception+import Prelude hiding (catch) import Control.Concurrent+import Control.Monad -testThread writeC n1 n2 = do+testThread writeC n1 n2 crash = do 	t <- myThreadId 	threadDelay $ n1 * 100000 	writeC("Thread " ++ show t ++ ": ") 	threadDelay $ n1 * 100000 	writeC "still working... "+        when crash $+            error "Thread crashed" 	writeC "" 	threadDelay $ n2 * 100000 	writeC "done\n"+        return True  main = do 	writeC <- getConcurrentOutputter-	mapM forkIO  $ zipWith (testThread writeC) [0,0,3,5,2,3] [4,8,5,4,1,2]-	threadDelay $ 15*100000+	forkSequence $ zipWith3 (testThread writeC) [0,0,3,5,2,3] [4,8,5,4,1,2] (False:True:repeat False)++-- Enable for parallel downloads+forkSequence acts = do+    sem <- newQSem 5+    mvars <- forM acts $ \act -> do+        mvar <- newEmptyMVar+        forkIO $ do +            waitQSem sem+            catch (act >>= putMVar mvar) (\e -> putMVar mvar (throw e))+            signalQSem sem+        return mvar+    mapM takeMVar mvars 	
concurrentoutput.cabal view
@@ -1,5 +1,5 @@ Name:            concurrentoutput-version:         0.2+version:         0.2.0.1 Category:        User Interfaces author:          Joachim Breitner maintainer:      Joachim Breitner <mail@joachim-breitner.de>@@ -12,23 +12,21 @@ 		 . 		 For example, this screen: 		 .-		 @Thread ThreadId 27: still working... done@-		 .-                 @Thread ThreadId 25: still working... @-		 .-                 @Thread ThreadId 26: still working... @-	         .-		 @_@-		 .-		 will, once thread 25 has finished, look like this-		 .	-                 @Thread ThreadId 25: still working... done@+		 @+		 Thread ThreadId 27: still working... done+                 Thread ThreadId 25: still working... +                 Thread ThreadId 26: still working... +		 _+		 @ 		 .-		 @Thread ThreadId 27: still working... done@+		 will, once thread 25 has finished, look like this: 		 .-                 @Thread ThreadId 26: still working... @-	         .-		 @_@+		 @+                 Thread ThreadId 25: still working... done+		 Thread ThreadId 27: still working... done+                 Thread ThreadId 26: still working... +		 _+		 @ 		 . 		 If standard output is not a terminal, it will only print 		 complete lines and not output any control characters.@@ -55,4 +53,4 @@ source-repository this   type:     darcs   location: http://darcs.nomeata.de/concurrentoutput/-  tag:      v0.2+  tag:      v0.2.0.1