-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Low-level bindings to epoll.
--
-- Bindings to epoll, a Linux specific I/O event notication facility (cf.
-- man epoll(7)).
@package epoll
@version 0.1
-- | Low level interface to Linux' epoll, a high performance polling
-- mechanism which handles high numbers of file descriptors efficiently.
-- See man epoll(7) for details.
module System.Linux.Epoll.Base
-- | EventType corresponds to epoll's event type defines, e.g. EPOLLIN,
-- EPOLLOUT, EPOLLET, etc.
data EventType
-- | Unsigned type used for length specifications.
data Size
toSize :: Int -> Maybe Size
-- | Unsigned type used for timeout specifications.
data Duration
toDuration :: Int -> Maybe Duration
-- | Event descriptor. Will be returned from add and must be passed
-- to delete exactly once.
data Descriptor a
-- | Abstract epoll device. Holds internal data. Returned from
-- create and used in almost every other API function. Must be
-- closed explicitely with close.
data Device
-- | A single event ocurrence.
data Event a
-- | Match operator. Useful to test whether an EventType returned
-- from wait contains one of the defined event types because
-- EventTypes returned by wait might be the bitwise OR of several
-- EventTypes.
(=~) :: EventType -> EventType -> Bool
-- | Creates an epoll device. Must be closed with close. The
-- parameter Size specifies the number of events that can be
-- reported by a single call to wait.
create :: Size -> IO Device
-- | Closes epoll device.
close :: Device -> IO ()
-- | Waits for the specified duration on all event descriptors. Returns the
-- list of events that occured.
wait :: Duration -> Device -> IO [Event a]
-- | Adds a filedescriptor to the epoll watch set using the specified
-- EventTypes. User data might be passed in as well which will be
-- returned on event occurence as part of the Event type. Returns
-- an event descriptor which must be deleted from the watch set with
-- delete.
add :: Device -> a -> [EventType] -> Fd -> IO (Descriptor a)
-- | Modified the event types of the event descriptor.
modify :: Device -> [EventType] -> Descriptor a -> IO ()
-- | Removes the event descriptor from the epoll watch set.
delete :: Device -> Descriptor a -> IO ()
inEvent :: EventType
outEvent :: EventType
peerCloseEvent :: EventType
urgentEvent :: EventType
errorEvent :: EventType
hangupEvent :: EventType
edgeTriggeredEvent :: EventType
oneShotEvent :: EventType
instance Eq Device
instance Show Device
instance Eq Duration
instance Ord Duration
instance Show Duration
instance Eq Size
instance Ord Size
instance Show Size
instance Eq Operation
instance Ord Operation
instance Eq EventType
instance Ord EventType
instance Show Operation
instance Show EventType
instance Storable EventStruct
module System.Linux.Epoll
-- | Repeatedly waits for epoll events and invokes the given callback
-- function with each event occured.
dispatchLoop :: Duration -> (Event a -> IO ()) -> Device -> IO ()
-- | Like dispatchLoop but uses a default Duration of 500ms.
defaultDispatchLoop :: (Event a -> IO ()) -> Device -> IO ()
-- | Monadic epoll interface. Similar to System.Linux.Epoll.Base but uses
-- ReaderT to hold a Device instead of passing it to many
-- functions.
module System.Linux.EpollM
data Epoll a
-- | Run Epoll monad.
runEpoll :: Device -> Epoll a -> IO a
-- | Run Epoll monad. Like runEpoll but creates and closes
-- Device implcitely.
runEpoll_ :: Size -> Epoll a -> IO a
-- | Like runEpoll_ but with an implicit Size value of 8.
runEpollSmall_ :: Epoll a -> IO a
-- | Like runEpoll_ but with an implicit Size value of 256.
runEpollMed_ :: Epoll a -> IO a
-- | Like runEpoll_ but with an implicit Size value of
-- 8192.
runEpollBig_ :: Epoll a -> IO a
-- | Adds the given file descriptor with the specified event types to
-- epoll.
add :: a -> [EventType] -> Fd -> Epoll (Descriptor a)
-- | Like add but without accepting custom data.
add_ :: [EventType] -> Fd -> Epoll (Descriptor ())
-- | Modify the event type set of the given descriptor.
modify :: [EventType] -> Descriptor a -> Epoll ()
-- | Deletes the descriptor from epoll.
delete :: Descriptor a -> Epoll ()
-- | Waits up to the given duration for events on all descriptors.
wait :: Duration -> Epoll [Event a]
-- | Like wait but uses a Duration of 500ms.
wait_ :: Epoll [Event a]
device :: Epoll Device
-- | Waits for events and calls the given function for each.
dispatchLoop :: Duration -> (Event a -> Epoll ()) -> Epoll ()
-- | Like dispatchLoop but forks itself into another thread
dispatchLoop_ :: Duration -> (Event a -> Epoll ()) -> Epoll ThreadId
-- | Like dispatchLoop but with predefined Duration of
-- 500ms.
defaultDispatchLoop :: (Event a -> Epoll ()) -> Epoll ()
-- | Like defaultDispatchLoop but forks itself into another thread
defaultDispatchLoop_ :: (Event a -> Epoll ()) -> Epoll ThreadId
-- | Uses forkIO to spark an epoll computation into another thread.
fork :: Epoll () -> Epoll ThreadId
-- | Like fork but swallows the ThreadId.
fork_ :: Epoll () -> Epoll ()
-- | EventType corresponds to epoll's event type defines, e.g. EPOLLIN,
-- EPOLLOUT, EPOLLET, etc.
data EventType
-- | Unsigned type used for length specifications.
data Size
toSize :: Int -> Maybe Size
-- | Unsigned type used for timeout specifications.
data Duration
toDuration :: Int -> Maybe Duration
-- | Event descriptor. Will be returned from add and must be passed
-- to delete exactly once.
data Descriptor a
-- | Abstract epoll device. Holds internal data. Returned from
-- create and used in almost every other API function. Must be
-- closed explicitely with close.
data Device
-- | A single event ocurrence.
data Event a
-- | Match operator. Useful to test whether an EventType returned
-- from wait contains one of the defined event types because
-- EventTypes returned by wait might be the bitwise OR of several
-- EventTypes.
(=~) :: EventType -> EventType -> Bool
-- | Creates an epoll device. Must be closed with close. The
-- parameter Size specifies the number of events that can be
-- reported by a single call to wait.
create :: Size -> IO Device
-- | Closes epoll device.
close :: Device -> IO ()
inEvent :: EventType
outEvent :: EventType
peerCloseEvent :: EventType
urgentEvent :: EventType
errorEvent :: EventType
hangupEvent :: EventType
edgeTriggeredEvent :: EventType
oneShotEvent :: EventType
instance Monad Epoll
instance MonadIO Epoll
instance MonadReader Device Epoll