module System.UDev.Queue
( Queue
, Seqnum
, newQueue
, isActive
, isEmpty
, isFinished
, getPending
, sequenceIsFinished
, getKernelSeqnum
, getUDevSeqnum
) where
import Control.Applicative
import Foreign.C
import System.UDev.Context
import System.UDev.List
import System.UDev.Types
foreign import ccall unsafe "udev_queue_new"
c_newQueue :: UDev -> IO Queue
newQueue :: UDev -> IO Queue
newQueue = c_newQueue
foreign import ccall unsafe "udev_queue_get_udev_is_active"
c_isActive :: Queue -> IO CInt
isActive :: Queue -> IO Bool
isActive queue = (0 <) <$> c_isActive queue
foreign import ccall unsafe "udev_queue_get_queue_is_empty"
c_isEmpty :: Queue -> IO CInt
isEmpty :: Queue -> IO Bool
isEmpty queue = (0 <) <$> c_isEmpty queue
foreign import ccall unsafe "udev_queue_get_seqnum_is_finished"
c_isFinished :: Queue -> CULLong -> IO CInt
type Seqnum = Int
isFinished :: Queue
-> Seqnum
-> IO Bool
isFinished queue seqnr = (0 <) <$> c_isFinished queue (fromIntegral seqnr)
foreign import ccall unsafe "udev_queue_get_seqnum_sequence_is_finished"
c_sequenceIsFinished :: Queue -> CULLong -> CULLong -> IO CInt
sequenceIsFinished :: Queue
-> Seqnum
-> Seqnum
-> IO Bool
sequenceIsFinished queue start end = do
(> 0) <$> c_sequenceIsFinished queue (fromIntegral start)
(fromIntegral end)
foreign import ccall unsafe "udev_queue_get_queued_list_entry"
c_getPending :: Queue -> IO List
getPending :: Queue -> IO List
getPending = c_getPending
foreign import ccall unsafe "udev_queue_get_kernel_seqnum"
c_getKernelSeqnum :: Queue -> IO CULLong
getKernelSeqnum :: Queue -> IO Seqnum
getKernelSeqnum queue = fromIntegral <$> c_getKernelSeqnum queue
foreign import ccall unsafe "udev_queue_get_udev_seqnum"
c_getUDevSeqnum :: Queue -> IO CULLong
getUDevSeqnum :: Queue -> IO Seqnum
getUDevSeqnum queue = fromIntegral <$> c_getUDevSeqnum queue