-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | FFI interface to libev
--
-- FFI interface to libev
@package hlibev
@version 0.2.1
-- | Network.Libev is a low-level binding to the libev library
-- (http://libev.schmorp.de/). The libev documentation is
-- available here:
-- http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod.
module Network.Libev
type EvLoopPtr = Ptr EvLoop
evDefaultLoop :: CInt -> IO EvLoopPtr
evLoopNew :: CUInt -> IO EvLoopPtr
evLoop :: EvLoopPtr -> CInt -> IO ()
evUnloop :: EvLoopPtr -> CInt -> IO ()
evLoopDestroy :: EvLoopPtr -> IO ()
-- | Returns the default set of CEvFlagType flags
evRecommendedBackends :: IO CEvFlagType
evflag_auto :: CEvFlagType
evflag_noenv :: CEvFlagType
evbackend_select :: CEvFlagType
evbackend_poll :: CEvFlagType
evbackend_epoll :: CEvFlagType
evbackend_kqueue :: CEvFlagType
evbackend_devpoll :: CEvFlagType
evbackend_port :: CEvFlagType
-- | CEventType is a bitfield used to flag whether a file descriptor
-- is readable, writable, or both. Valid values are ev_read and
-- ev_write. TODO: deprecate and replace by a datatype
type CEventType = CInt
-- | CEvFlagType is a bitfield used to pass flags into
-- evDefaultLoop. Values (evflag_auto, evflag_noenv,
-- etc.) are combined with bitwise or. TODO: replace with a newtype with
-- a monoid instance
type CEvFlagType = CInt
ev_read :: CEventType
ev_write :: CEventType
type EvIoPtr = Ptr EvIo
-- | An IoCallback is called when a file descriptor becomes readable
-- or writable. It takes a pointer to an ev_loop structure, a
-- pointer to an ev_io structure, and an event mask.
type IoCallback = EvLoopPtr -> EvIoPtr -> CEventType -> IO ()
-- | Makes a new ev_io struct using malloc. You are
-- responsible for freeing it with freeEvIo.
mkEvIo :: IO (EvIoPtr)
-- | Makes a new ev_timer struct using malloc. You are
-- responsible for freeing it with freeEvTimer.
mkEvTimer :: IO (EvTimerPtr)
-- | free() an EvIoPtr
freeEvIo :: EvIoPtr -> IO ()
-- | free() an EvIoPtr
freeEvTimer :: EvTimerPtr -> IO ()
-- | Wrap up an IoCallback so it can be delivered into C-land. This
-- resource is not garbage-collected, you are responsible for freeing it
-- with freeIoCallback.
mkIoCallback :: IoCallback -> IO (FunPtr IoCallback)
-- | Wrap up a TimerCallback so it can be delivered into C-land.
-- This resource is not garbage-collected, you are responsible for
-- freeing it with freeTimerCallback.
mkTimerCallback :: TimerCallback -> IO (FunPtr TimerCallback)
freeIoCallback :: FunPtr IoCallback -> IO ()
freeTimerCallback :: FunPtr TimerCallback -> IO ()
evIoInit :: EvIoPtr -> FunPtr IoCallback -> CInt -> CEventType -> IO ()
evIoStart :: EvLoopPtr -> EvIoPtr -> IO ()
evIoStop :: EvLoopPtr -> EvIoPtr -> IO ()
type EvTimerPtr = Ptr EvTimer
-- | A TimerCallback is called when a timer expires. It takes a
-- pointer to an ev_loop structure, a pointer to an
-- ev_io structure, and an (unused?) event mask.
type TimerCallback = EvLoopPtr -> EvTimerPtr -> CEventType -> IO ()
evTimerInit :: EvTimerPtr -> FunPtr TimerCallback -> EvTimestamp -> EvTimestamp -> IO ()
evTimerStart :: EvLoopPtr -> EvTimerPtr -> IO ()
evTimerStop :: EvLoopPtr -> EvTimerPtr -> IO ()
-- | Libev timestamp values are C doubles containing the (floating) number
-- of seconds since Jan 1, 1970.
type EvTimestamp = CDouble
-- | Fetch a the cached copy of the current time from a loop.
evNow :: EvLoopPtr -> IO EvTimestamp
-- | Fetches the current time from the operating system. Usually
-- evNow is preferred since it avoids a context switch by
-- returning a cached value.
evTime :: IO EvTimestamp
-- | Calls accept() and sets the socket non-blocking.
c_accept :: CInt -> IO (CInt)
c_close :: CInt -> IO (CInt)
c_read :: CInt -> CString -> CSize -> IO (CSize)
c_write :: CInt -> CString -> CSize -> IO (CSize)
c_setnonblocking :: CInt -> IO ()
instance Storable EvTimer
instance Storable EvIo
instance Storable EvWatcher