Struct futures_glib::Source
[−]
[src]
pub struct Source<T> { /* fields omitted */ }
A binding to the GSource
underlying type.
Methods
impl<T: SourceFuncs> Source<T>
[src]
fn new(t: T) -> Source<T>
Creates a new GSource
structure.
The source will not initially be associated with any MainContext
and
must be added to one with attach
before it will be executed.
fn get_ref(&self) -> &T
Acquires an underlying reference to the data contained within this
Source
.
fn attach(&self, context: &MainContext)
Adds a Source
to a context so that it will be executed within that
context.
fn destroy(&self)
Removes a source from its MainContext
, if any, and mark it as
destroyed.
The source cannot be subsequently added to another context. It is safe to call this on sources which have already been removed from their context.
fn set_priority(&self, priority: i32)
Sets the priority of a source.
While the main loop is being run, a source will be dispatched if it is ready to be dispatched and no sources at a higher (numerically smaller) priority are ready to be dispatched.
A child source always has the same priority as its parent. It is not permitted to change the priority of a source once it has been added as a child of another source.
fn priority(&self) -> i32
Gets the priority of a source.
fn set_can_recurse(&self, can_recurse: bool)
Sets whether a source can be called recursively.
If can_recurse is true
, then while the source is being dispatched then
this source will be processed normally. Otherwise, all processing of
this source is blocked until the dispatch function returns.
fn can_recurse(&self) -> bool
Checks whether a source is allowed to be called recursively.
fn get_id(&self) -> u32
Returns the numeric ID for a particular source.
The ID of a source is a positive integer which is unique within a particular main loop context.
fn context(&self) -> Option<MainContext>
Gets the MainContext
with which the source is associated.
fn set_callback<F>(&self, f: F) where
F: FnMut(T::CallbackArg) -> bool + 'static,
F: FnMut(T::CallbackArg) -> bool + 'static,
Sets the callback function for a source. The callback for a source is called from the source's dispatch function.
fn set_ready_time(&self, ready_time: Option<Instant>)
Sets a Source
to be dispatched when the given monotonic time is
reached (or passed). If the monotonic time is in the past (as it always
will be if ready_time is the current time) then the source will be
dispatched immediately.
If ready_time is None
then the source is never woken up on the basis
of the passage of time.
Dispatching the source does not reset the ready time. You should do so yourself, from the source dispatch function.
Note that if you have a pair of sources where the ready time of one suggests that it will be delivered first but the priority for the other suggests that it would be delivered first, and the ready time for both sources is reached during the same main context iteration then the order of dispatch is undefined.
This API is only intended to be used by implementations of Source
. Do
not call this API on a Source
that you did not create.
fn unix_add_fd(&self, fd: i32, events: &IoCondition) -> UnixToken
Monitors fd for the IO events in events.
The token returned by this function can be used to remove or modify the
monitoring of the fd using unix_remove_fd
or unix_modify_fd
.
It is not necessary to remove the fd before destroying the source; it will be cleaned up automatically.
This API is only intended to be used by implementations of Source
. Do
not call this API on a Source
that you did not create.
As the name suggests, this function is not available on Windows.
unsafe fn unix_modify_fd(&self, token: &UnixToken, events: &IoCondition)
Updates the event mask to watch for the fd identified by tag .
token
is the token returned from unix_add_fd
If you want to remove a fd, don't set its event mask to zero. Instead,
call remove_unix_fd
This API is only intended to be used by implementations of Source
. Do
not call this API on a Source
that you did not create.
As the name suggests, this function is not available on Windows.
Unsafety
This function can only be called with tokens that were returned from
this source's unix_add_fd
implementation and haven't been removed yet.
unsafe fn unix_remove_fd(&self, token: &UnixToken)
Reverses the effect of a previous call to unix_add_fd
.
You only need to call this if you want to remove an fd from being watched while keeping the same source around. In the normal case you will just want to destroy the source.
This API is only intended to be used by implementations of Source
. Do
not call this API on a Source
that you did not create.
As the name suggests, this function is not available on Windows.
Unsafety
This function can only be called with tokens that were returned from
this source's unix_add_fd
implementation and haven't been removed yet.
unsafe fn unix_query_fd(&self, token: &UnixToken) -> IoCondition
Queries the events reported for the fd corresponding to token on source during the last poll.
The return value of this function is only defined when the function is called from the check or dispatch functions for source.
This API is only intended to be used by implementations of Source
. Do
not call this API on a Source
that you did not create.
As the name suggests, this function is not available on Windows.
Unsafety
This function can only be called with tokens that were returned from
this source's unix_add_fd
implementation and haven't been removed yet.
Trait Implementations
impl<T> Clone for Source<T>
[src]
fn clone(&self) -> Source<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more