Safe Haskell | None |
---|
System.Posix.MQueue
Contents
Description
Create a circular buffer over shared memory that can be accessed from - separate processes. - - This module assumes that exactly one WriteBuffer and one ReadBuffer will be - used to access the same shared memory object. The ReadBuffer and - WriteBuffer may exist in separate processes. - - to use this library, in one process - - > bracket (createBuffer aBuffer aSemaphore 256 0o600) (removeBuffer) - > (buffer -> doSomethingWith buffer) - - and in the other - - > bracket (openBuffer aBuffer aSemaphore 256 0o600) (closeBuffer) - > (buffer -> doSomethingWith buffer) - - The buffer may be opened from either the reader or writer end, but you - should ensure that the buffer is created before it is opened. - - As the underlying objects (shm and named posix semaphores) exist in the file - system, failing to call removeBuffer will leave stale objects in the - filesystem. - - Opening multiple ReadBuffers or WriteBuffers with the same names (whether in - one process or several) results in undefined behavior.
- data WriteBuffer a
- data ReadBuffer a
- class Shared b where
- createBuffer :: String -> String -> Int -> FileMode -> IO b
- openBuffer :: String -> String -> Int -> FileMode -> IO b
- closeBuffer :: b -> IO ()
- removeBuffer :: b -> IO ()
- unlinkBuffer :: b -> IO ()
- putBuffer :: Storable a => WriteBuffer a -> a -> IO ()
- getBuffer :: forall a. Storable a => ReadBuffer a -> IO a
- putBufferList :: Storable a => WriteBuffer a -> [a] -> IO ()
- getAvailable :: Storable a => ReadBuffer a -> IO [a]
Documentation
data WriteBuffer a Source
Instances
Storable a => Shared (WriteBuffer a) |
data ReadBuffer a Source
Instances
Storable a => Shared (ReadBuffer a) |
Functions for creatingopeningclosing/removing shared buffers.
Methods
createBuffer :: String -> String -> Int -> FileMode -> IO bSource
openBuffer :: String -> String -> Int -> FileMode -> IO bSource
closeBuffer :: b -> IO ()Source
removeBuffer :: b -> IO ()Source
unlinkBuffer :: b -> IO ()Source
normal interface
putBuffer :: Storable a => WriteBuffer a -> a -> IO ()Source
Write a value to the writer end.
This function is thread-safe.
getBuffer :: forall a. Storable a => ReadBuffer a -> IO aSource
read the next value from the reader end.
This function is *NOT* thread-safe.
putBufferList :: Storable a => WriteBuffer a -> [a] -> IO ()Source
Write a list of values to the writer end.
This function is thread-safe.
getAvailable :: Storable a => ReadBuffer a -> IO [a]Source
read all currently available values from the reader end.
This function is *NOT* thread-safe.