ipc 0.0.2 → 0.0.3
raw patch · 4 files changed
+37/−1 lines, 4 files
Files
- Data/Queue.hs +13/−0
- Test/recver.hs +12/−0
- Test/sender.hs +11/−0
- ipc.cabal +1/−1
Data/Queue.hs view
@@ -7,6 +7,9 @@ , snoc , pop , cons+ , append+ , Data.Queue.foldr+ , Data.Queue.map , send , recv , sendAtomic@@ -41,6 +44,16 @@ -- |Places an element at the front of the queue. O(1) cons :: a -> Queue d a -> Queue d a cons e (Q d n) = Q (D.cons e d) (n + 1)++-- |Combine two queues.+append :: Queue d a -> Queue d a -> Queue d a+append (Q q i) (Q p j) = Q (D.append q p) (i + j)++map :: (a -> b) -> Queue d a -> Queue d b+map f (Q xs len) = Q (D.map f xs) len++foldr :: (a -> b -> b) -> b -> Queue d a -> b+foldr f z (Q xs len) = D.foldr f z xs -- |IO action for snoc on a TVar queue send :: TVar (Queue Output a) -> a -> IO ()
+ Test/recver.hs view
@@ -0,0 +1,12 @@+module Main where++import System.IPC+import Control.Concurrent.STM+import Control.Concurrent (threadDelay)+import Control.Monad ++main = do+ q <- channelAcceptSimple "Test"+ forever (do x <- recv q+ putStrLn x )+ threadDelay 10000
+ Test/sender.hs view
@@ -0,0 +1,11 @@+module Main where++import System.IPC+import Control.Concurrent.STM+import Control.Concurrent++main = do+ q <- channelConnectSimple "Test"+ mapM_ (\x -> send q ("Hello: " ++ (show x))) [1..1000]+ waitTillEmpty q+ threadDelay 1000
ipc.cabal view
@@ -1,5 +1,5 @@ name: ipc-version: 0.0.2+version: 0.0.3 synopsis: High level inter-process communication library description: Provides inter-process communication at a high level Copyright: 2008, Thomas DuBuisson