Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
A Poll
keeps track of file descriptors much like fd_set (used with
select()
) or a struct pollfd array (used with poll()
). Once created with
gst_poll_new()
, the set can be used to wait for file descriptors to be
readable and/or writable. It is possible to make this wait be controlled
by specifying True
for the controllable
flag when creating the set (or
later calling pollSetControllable
).
New file descriptors are added to the set using pollAddFd
, and
removed using pollRemoveFd
. Controlling which file descriptors
should be waited for to become readable and/or writable are done using
pollFdCtlRead
and pollFdCtlWrite
.
Use pollWait
to wait for the file descriptors to actually become
readable and/or writable, or to timeout if no file descriptor is available
in time. The wait can be controlled by calling pollRestart
and
pollSetFlushing
.
Once the file descriptor set has been waited for, one can use
pollFdHasClosed
to see if the file descriptor has been closed,
pollFdHasError
to see if it has generated an error,
pollFdCanRead
to see if it is possible to read from the file
descriptor, and pollFdCanWrite
to see if it is possible to
write to it.
- newtype Poll = Poll (ManagedPtr Poll)
- noPoll :: Maybe Poll
- data PollAddFdMethodInfo
- pollAddFd :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m Bool
- data PollFdCanReadMethodInfo
- pollFdCanRead :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m Bool
- data PollFdCanWriteMethodInfo
- pollFdCanWrite :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m Bool
- data PollFdCtlReadMethodInfo
- pollFdCtlRead :: (HasCallStack, MonadIO m) => Poll -> PollFD -> Bool -> m Bool
- data PollFdCtlWriteMethodInfo
- pollFdCtlWrite :: (HasCallStack, MonadIO m) => Poll -> PollFD -> Bool -> m Bool
- data PollFdHasClosedMethodInfo
- pollFdHasClosed :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m Bool
- data PollFdHasErrorMethodInfo
- pollFdHasError :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m Bool
- data PollFdIgnoredMethodInfo
- pollFdIgnored :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m ()
- data PollGetReadGpollfdMethodInfo
- pollGetReadGpollfd :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m ()
- data PollReadControlMethodInfo
- pollReadControl :: (HasCallStack, MonadIO m) => Poll -> m Bool
- data PollRemoveFdMethodInfo
- pollRemoveFd :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m Bool
- data PollRestartMethodInfo
- pollRestart :: (HasCallStack, MonadIO m) => Poll -> m ()
- data PollSetControllableMethodInfo
- pollSetControllable :: (HasCallStack, MonadIO m) => Poll -> Bool -> m Bool
- data PollSetFlushingMethodInfo
- pollSetFlushing :: (HasCallStack, MonadIO m) => Poll -> Bool -> m ()
- data PollWaitMethodInfo
- pollWait :: (HasCallStack, MonadIO m) => Poll -> Word64 -> m Int32
- data PollWriteControlMethodInfo
- pollWriteControl :: (HasCallStack, MonadIO m) => Poll -> m Bool
Exported types
Methods
addFd
data PollAddFdMethodInfo Source #
((~) * signature (PollFD -> m Bool), MonadIO m) => MethodInfo * PollAddFdMethodInfo Poll signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> m Bool | Returns: |
Add a file descriptor to the file descriptor set.
fdCanRead
data PollFdCanReadMethodInfo Source #
((~) * signature (PollFD -> m Bool), MonadIO m) => MethodInfo * PollFdCanReadMethodInfo Poll signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> m Bool | Returns: |
Check if fd
in set
has data to be read.
fdCanWrite
data PollFdCanWriteMethodInfo Source #
((~) * signature (PollFD -> m Bool), MonadIO m) => MethodInfo * PollFdCanWriteMethodInfo Poll signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> m Bool | Returns: |
Check if fd
in set
can be used for writing.
fdCtlRead
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> Bool |
|
-> m Bool | Returns: |
Control whether the descriptor fd
in set
will be monitored for
readability.
fdCtlWrite
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> Bool |
|
-> m Bool | Returns: |
Control whether the descriptor fd
in set
will be monitored for
writability.
fdHasClosed
data PollFdHasClosedMethodInfo Source #
((~) * signature (PollFD -> m Bool), MonadIO m) => MethodInfo * PollFdHasClosedMethodInfo Poll signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> m Bool | Returns: |
Check if fd
in set
has closed the connection.
fdHasError
data PollFdHasErrorMethodInfo Source #
((~) * signature (PollFD -> m Bool), MonadIO m) => MethodInfo * PollFdHasErrorMethodInfo Poll signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> m Bool | Returns: |
Check if fd
in set
has an error.
fdIgnored
data PollFdIgnoredMethodInfo Source #
((~) * signature (PollFD -> m ()), MonadIO m) => MethodInfo * PollFdIgnoredMethodInfo Poll signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> m () |
Mark fd
as ignored so that the next call to pollWait
will yield
the same result for fd
as last time. This function must be called if no
operation (read/write/recv/send/etc.) will be performed on fd
before
the next call to pollWait
.
The reason why this is needed is because the underlying implementation might not allow querying the fd more than once between calls to one of the re-enabling operations.
getReadGpollfd
data PollGetReadGpollfdMethodInfo Source #
((~) * signature (PollFD -> m ()), MonadIO m) => MethodInfo * PollGetReadGpollfdMethodInfo Poll signature Source # | |
Get a GPollFD for the reading part of the control socket. This is useful when integrating with a GSource and GMainLoop.
readControl
data PollReadControlMethodInfo Source #
((~) * signature (m Bool), MonadIO m) => MethodInfo * PollReadControlMethodInfo Poll signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> m Bool | Returns: |
Read a byte from the control socket of the controllable set
.
This function only works for timer Poll
objects created with
gst_poll_new_timer()
.
removeFd
data PollRemoveFdMethodInfo Source #
((~) * signature (PollFD -> m Bool), MonadIO m) => MethodInfo * PollRemoveFdMethodInfo Poll signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> m Bool | Returns: |
Remove a file descriptor from the file descriptor set.
restart
data PollRestartMethodInfo Source #
((~) * signature (m ()), MonadIO m) => MethodInfo * PollRestartMethodInfo Poll signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> m () |
setControllable
data PollSetControllableMethodInfo Source #
((~) * signature (Bool -> m Bool), MonadIO m) => MethodInfo * PollSetControllableMethodInfo Poll signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> Bool |
|
-> m Bool | Returns: |
When controllable
is True
, this function ensures that future calls to
pollWait
will be affected by pollRestart
and
pollSetFlushing
.
This function only works for non-timer Poll
objects created with
gst_poll_new()
.
setFlushing
data PollSetFlushingMethodInfo Source #
((~) * signature (Bool -> m ()), MonadIO m) => MethodInfo * PollSetFlushingMethodInfo Poll signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> Bool |
|
-> m () |
wait
data PollWaitMethodInfo Source #
((~) * signature (Word64 -> m Int32), MonadIO m) => MethodInfo * PollWaitMethodInfo Poll signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> Word64 |
|
-> m Int32 | Returns: The number of |
Wait for activity on the file descriptors in set
. This function waits up to
the specified timeout
. A timeout of CLOCK_TIME_NONE
waits forever.
For Poll
objects created with gst_poll_new()
, this function can only be
called from a single thread at a time. If called from multiple threads,
-1 will be returned with errno set to EPERM.
This is not true for timer Poll
objects created with
gst_poll_new_timer()
, where it is allowed to have multiple threads waiting
simultaneously.
writeControl
data PollWriteControlMethodInfo Source #
((~) * signature (m Bool), MonadIO m) => MethodInfo * PollWriteControlMethodInfo Poll signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> m Bool | Returns: |
Write a byte to the control socket of the controllable set
.
This function is mostly useful for timer Poll
objects created with
gst_poll_new_timer()
.
It will make any current and future pollWait
function return with
1, meaning the control socket is set. After an equal amount of calls to
pollReadControl
have been performed, calls to pollWait
will
block again until their timeout expired.
This function only works for timer Poll
objects created with
gst_poll_new_timer()
.