Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
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
, pollFdCtlWrite
and pollFdCtlPri
.
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.
Synopsis
- newtype Poll = Poll (ManagedPtr Poll)
- pollAddFd :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m Bool
- pollFdCanRead :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m Bool
- pollFdCanWrite :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m Bool
- pollFdCtlPri :: (HasCallStack, MonadIO m) => Poll -> PollFD -> Bool -> m Bool
- pollFdCtlRead :: (HasCallStack, MonadIO m) => Poll -> PollFD -> Bool -> m Bool
- pollFdCtlWrite :: (HasCallStack, MonadIO m) => Poll -> PollFD -> Bool -> m Bool
- pollFdHasClosed :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m Bool
- pollFdHasError :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m Bool
- pollFdHasPri :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m Bool
- pollFdIgnored :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m ()
- pollGetReadGpollfd :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m ()
- pollReadControl :: (HasCallStack, MonadIO m) => Poll -> m Bool
- pollRemoveFd :: (HasCallStack, MonadIO m) => Poll -> PollFD -> m Bool
- pollRestart :: (HasCallStack, MonadIO m) => Poll -> m ()
- pollSetControllable :: (HasCallStack, MonadIO m) => Poll -> Bool -> m Bool
- pollSetFlushing :: (HasCallStack, MonadIO m) => Poll -> Bool -> m ()
- pollWait :: (HasCallStack, MonadIO m) => Poll -> Word64 -> m Int32
- pollWriteControl :: (HasCallStack, MonadIO m) => Poll -> m Bool
Exported types
Memory-managed wrapper type.
Instances
Eq Poll Source # | |
BoxedPtr Poll Source # | |
Defined in GI.Gst.Structs.Poll boxedPtrCopy :: Poll -> IO Poll boxedPtrFree :: Poll -> IO () | |
ManagedPtrNewtype Poll Source # | |
Defined in GI.Gst.Structs.Poll toManagedPtr :: Poll -> ManagedPtr Poll |
Methods
Click to display all available methods, including inherited ones
Methods
addFd, fdCanRead, fdCanWrite, fdCtlPri, fdCtlRead, fdCtlWrite, fdHasClosed, fdHasError, fdHasPri, fdIgnored, readControl, removeFd, restart, wait, writeControl.
Getters
Setters
addFd
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> m Bool | Returns: |
Add a file descriptor to the file descriptor set.
fdCanRead
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> m Bool | Returns: |
Check if fd
in set
has data to be read.
fdCanWrite
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> m Bool | Returns: |
Check if fd
in set
can be used for writing.
fdCtlPri
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> Bool |
|
-> m Bool | Returns: |
Control whether the descriptor fd
in set
will be monitored for
exceptional conditions (POLLPRI).
Not implemented on Windows (will just return False
there).
Since: 1.16
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
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> m Bool | Returns: |
Check if fd
in set
has closed the connection.
fdHasError
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> m Bool | Returns: |
Check if fd
in set
has an error.
fdHasPri
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> m Bool | Returns: |
Check if fd
in set
has an exceptional condition (POLLPRI).
Not implemented on Windows (will just return False
there).
Since: 1.16
fdIgnored
:: (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
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> m () |
Get a GPollFD for the reading part of the control socket. This is useful when integrating with a GSource and GMainLoop.
readControl
:: (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
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> PollFD |
|
-> m Bool | Returns: |
Remove a file descriptor from the file descriptor set.
restart
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> m () |
setControllable
:: (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
:: (HasCallStack, MonadIO m) | |
=> Poll |
|
-> Bool |
|
-> m () |
wait
:: (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
:: (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()
.