packages feed

eprocess 1.0.0 → 1.1.0

raw patch · 2 files changed

+23/−10 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Control.Concurrent.Process: kill :: (MonadIO m) => Handle a -> m ()

Files

eprocess.cabal view
@@ -1,5 +1,5 @@ name: eprocess-version: 1.0.0+version: 1.1.0 cabal-version: >=1.6 build-type: Simple license: BSD3@@ -10,7 +10,7 @@ package-url: http://code.haskell.org/eprocess bug-reports: http://github.com/elbrujohalcon/eprocess/issues synopsis: *Very* basic erlang-like process support for Haskel-description: This library provides a *very* basic support for processes with message queues.  It was built using channels and MVars.+description: This library provides a *very* basic support for processes with message queues.  It was built using channels, threads and MVars. Since version 1.1.0 you can also kill a running process. category: Concurrency author: Fernando "Brujo" Benavides tested-with: GHC ==6.10.3, GHC ==6.10.4
src/Control/Concurrent/Process.hs view
@@ -9,8 +9,8 @@ -- * Types         ReceiverT, Handle, Process,  -- * Functions--- ** Process creation -        makeProcess, runHere, spawn,+-- ** Process creation / destruction+        makeProcess, runHere, spawn, kill, -- ** Message passing         self, sendTo, recv, sendRecv     ) where@@ -26,7 +26,8 @@  -- | A Process handle.  It's returned on process creation and should be used -- | afterwards to send messages to it-newtype Handle r = PH {chan :: Chan r}+data Handle r = PH {chan     :: Chan r,+                    thread   :: ThreadId}  -- | The /ReceiverT/ generic type. -- @@ -50,6 +51,14 @@         -> m () sendTo ph = liftIO . writeChan (chan ph) +-- | /kill/ lets you *brutally* terminate a running process. Usage:+-- @+--      kill processHandle+-- @+kill :: MonadIO m => Handle a -- ^ The handle of process to kill+        -> m ()+kill = liftIO . killThread . thread+ -- | /recv/ lets you receive a message in a running process (it's a blocking receive). Usage: -- @ --      message <- recv@@ -74,10 +83,11 @@         -> m (Handle r)                 -- ^ The handle for that process spawn p = liftIO $ do                  pChan <- newChan-                 let handle = PH { chan = pChan }-                 let action = runReaderT (internalReader p) handle-                 forkIO $ action >> return ()-                 return handle+                 pThread <- forkIO $ do+                                         t <- myThreadId+                                         runReaderT (internalReader p) $ PH pChan t+                                         return ()+                 return $ PH pChan pThread  -- | /runHere/ executes process code in the current environment. Usage: -- @@@ -85,7 +95,10 @@ -- @ runHere :: MonadIO m => Process r t     -- ^ The process to be run          -> m t                         -- ^ It's returned as an action-runHere p = liftIO (runReaderT (internalReader p) . PH =<< newChan)+runHere p = liftIO $ do+                        c <- newChan+                        t <- myThreadId+                        runReaderT (internalReader p) $ PH c t  -- | /self/ returns the handle of the current process. Usage: -- @