-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Send messages to a handle concurrently without getting them mixed.
--   
--   Do you have a program that output messages to the screen from
--   different threads and you are tired of getting them all messed up?
--   Welcome to the <i>post-mess-age</i>. Using a simple <i>passer
--   object</i> you can make your logging messages useful again. The
--   methodology is explained in the API docs. You can use post-mess-age
--   not only for the <a>stdout</a> handle, but with anything!
@package post-mess-age
@version 0.2.1.0


-- | Mechanism to get messages sent to a handle concurrently without
--   getting them mixed. They are sent to the handle in the same order they
--   are received by a <i>passer object</i> (see <a>Passer</a>), not
--   sending a message before the previous message is sent completely.
module Control.Concurrent.PostMessAge

-- | The <a>Passer</a> is the object that you send the messages to. It will
--   redirect this message to its attached handle, making sure the messages
--   are not intercalated. Use <a>postMessage</a> to send message to a
--   passer object.
data Passer handle msg

-- | Create a passer object from a handle and a function to send values to
--   that handle.
--   
--   Example:
--   
--   <pre>
--   createPasser stderr hPutStrLn
--   </pre>
createPasser :: handle -> (handle -> msg -> IO ()) -> IO (Passer handle msg)

-- | Close a passer object, so it won't receive any more messages in the
--   future. Once a passer object is closed, it can't be re-opened again.
--   If you want to reuse a handle, create another passer object with
--   <a>createPasser</a>.
closePasser :: Passer handle msg -> IO ()

-- | Send a message to a passer object. It returns a value indicating if
--   the message reached the passer object.
postMessage :: Passer handle msg -> msg -> IO Bool

-- | Check if a passer object is closed. When a passer object is closed, it
--   won't send any more messages to its attached handle. This does not
--   mean the handle itself is closed.
isPasserClosed :: Passer handle msg -> IO Bool

-- | Check if a passer object is open. While a passer object is open, all
--   the messages received by the passer are sent to its attached handle.
isPasserOpen :: Passer handle msg -> IO Bool

-- | Return the handle used by a passer object.
passerHandle :: Passer handle msg -> handle
