Poll
Object Hierarchy:
Description:
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 Poll, the
set can be used to wait for file descriptors to be readable and/or writeable. It is possible to make this wait be controlled by specifying
true for the controllable flag when creating the set (or later calling
set_controllable). New file descriptors are added to the set using
add_fd, and removed using remove_fd
. Controlling which file descriptors should be waited for to become readable and/or writeable are done using
ctl_read and
ctl_write. Use wait to wait for the file descriptors to actually become readable
and/or writeable, or to timeout if no file descriptor is available in time. The wait can be controlled by calling
restart and set_flushing. Once
the file descriptor set has been waited for, one can use has_closed to see
if the file descriptor has been closed, has_error to see if it has generated
an error, can_read to see if it is possible to read from the file descriptor,
and can_write to see if it is possible to write to it.
Namespace: Gst
Package: gstreamer-0.10
Content:
Creation methods:
-
public Poll (bool controllable)
Create a new file descriptor set. If controllable, it is possible to restart or flush a
call to wait with restart and
set_flushing respectively. Free with gst_poll_free.
-
public Poll.timer ()
Create a new poll object that can be used for scheduling cancellable timeouts. A timeout is performed
with wait. Multiple timeouts can be performed from different threads. Free with
gst_poll_free.
Methods:
-
public bool add_fd (PollFD fd)
Add a file descriptor to the file descriptor set.
-
public void get_read_gpollfd (PollFD fd)
Get a GPollFD for the reading part of the control socket. This is useful when integrating with a GSource
and GMainLoop.
-
public bool read_control ()
Read a byte from the control socket of the controllable set. This function is mostly useful
for timer Poll objects created with
Poll.timer. was no byte to read.
-
public bool remove_fd (PollFD fd)
Remove a file descriptor from the file descriptor set.
-
public void restart ()
Restart any wait that is in progress. This function is
typically used after adding or removing descriptors to set. If set is not controllable, then this call will
have no effect.
-
public bool set_controllable (bool controllable)
When controllable is true, this function ensures that future calls to
wait will be affected by restart
and set_flushing.
-
public void set_flushing (bool flushing)
When flushing is true, this function ensures that current and future calls to
wait will return -1, with errno set to EBUSY. Unsetting the flushing state will
restore normal operation of set.
-
public int wait (ClockTime timeout)
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 Poll,
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
Poll.timer, where it is allowed to have multiple threads waiting
simultaneously. activity was detected after timeout. If an error occurs, -1 is returned and errno is set.
-
public bool write_control ()
Write a byte to the control socket of the controllable set. This function is mostly useful
for timer Poll objects created with
Poll.timer. It will make any current and future
wait function return with 1, meaning the control socket is set. After an equal amount
of calls to read_control have been performed, calls to
wait will block again until their timeout expired. byte could not be written.