epoll-0.1: Low-level bindings to epoll.

Portabilitynon-portable
Stabilityexperimental
Maintainertoralf.wittner@gmail.com

System.Linux.EpollM

Description

Monadic epoll interface. Similar to System.Linux.Epoll.Base but uses ReaderT to hold a Device instead of passing it to many functions.

Synopsis

Documentation

runEpoll :: Device -> Epoll a -> IO aSource

Run Epoll monad.

runEpoll_ :: Size -> Epoll a -> IO aSource

Run Epoll monad. Like runEpoll but creates and closes Device implcitely.

runEpollSmall_ :: Epoll a -> IO aSource

Like runEpoll_ but with an implicit Size value of 8.

runEpollMed_ :: Epoll a -> IO aSource

Like runEpoll_ but with an implicit Size value of 256.

runEpollBig_ :: Epoll a -> IO aSource

Like runEpoll_ but with an implicit Size value of 8192.

add :: a -> [EventType] -> Fd -> Epoll (Descriptor a)Source

Adds the given file descriptor with the specified event types to epoll.

add_ :: [EventType] -> Fd -> Epoll (Descriptor ())Source

Like add but without accepting custom data.

modify :: [EventType] -> Descriptor a -> Epoll ()Source

Modify the event type set of the given descriptor.

delete :: Descriptor a -> Epoll ()Source

Deletes the descriptor from epoll.

wait :: Duration -> Epoll [Event a]Source

Waits up to the given duration for events on all descriptors.

wait_ :: Epoll [Event a]Source

Like wait but uses a Duration of 500ms.

dispatchLoop :: Duration -> (Event a -> Epoll ()) -> Epoll ()Source

Waits for events and calls the given function for each.

dispatchLoop_ :: Duration -> (Event a -> Epoll ()) -> Epoll ThreadIdSource

Like dispatchLoop but forks itself into another thread

defaultDispatchLoop :: (Event a -> Epoll ()) -> Epoll ()Source

Like dispatchLoop but with predefined Duration of 500ms.

defaultDispatchLoop_ :: (Event a -> Epoll ()) -> Epoll ThreadIdSource

Like defaultDispatchLoop but forks itself into another thread

fork :: Epoll () -> Epoll ThreadIdSource

Uses forkIO to spark an epoll computation into another thread.

fork_ :: Epoll () -> Epoll ()Source

Like fork but swallows the ThreadId.

data EventType Source

EventType corresponds to epoll's event type defines, e.g. EPOLLIN, EPOLLOUT, EPOLLET, etc.

data Size Source

Unsigned type used for length specifications.

Instances

data Duration Source

Unsigned type used for timeout specifications.

data Descriptor a Source

Event descriptor. Will be returned from add and must be passed to delete exactly once.

data Device Source

Abstract epoll device. Holds internal data. Returned from create and used in almost every other API function. Must be closed explicitely with close.

data Event a Source

A single event ocurrence.

(=~) :: EventType -> EventType -> BoolSource

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.

create :: Size -> IO DeviceSource

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.

close :: Device -> IO ()Source

Closes epoll device.