Struct libpulse_binding::mainloop::standard::Mainloop
[−]
[src]
pub struct Mainloop { pub _inner: Rc<MainloopInner<MainloopInternal>>, }
This acts as a safe interface to the internal PA Mainloop.
The mainloop object pointers are further enclosed here in a ref counted wrapper, allowing this outer wrapper to have clean methods for creating event objects, which can cleanly pass a copy of the inner ref counted mainloop object to them. Giving this to events serves two purposes, firstly because they need the API pointer, secondly, it ensures that event objects do not outlive the mainloop object.
Fields
_inner: Rc<MainloopInner<MainloopInternal>>
The ref-counted inner data
Methods
impl Mainloop
[src]
fn new() -> Option<Self>
[src]
Allocate a new main loop object
fn prepare(&self, timeout: Option<i32>) -> Result<(), i32>
[src]
Prepare for a single iteration of the main loop.
Returns Err
on error or exit request.
timeout
specifies a maximum timeout for the subsequent poll, or None
for blocking
behaviour. Only positive values should be provided, negative values will have the same
effect as None
.
fn poll(&self) -> Result<u32, i32>
[src]
Execute the previously prepared poll.
fn dispatch(&self) -> Result<u32, i32>
[src]
Dispatch timeout, io and deferred events from the previously executed poll. On success returns the number of source dispatched.
fn get_retval(&self) -> i32
[src]
Return the return value as specified with the main loop's quit
routine.
fn iterate(&self, block: bool) -> InterateResult
[src]
Run a single iteration of the main loop.
This is a convenience function for prepare
, poll
and dispatch
.
If block
is true
, block for events if none are queued.
Returns an InterateResult
variant:
- On success, returns
InterateResult::Success
containing the number of sources dispatched in this iteration. - If exit was requested, returns
InterateResult::Quit
containing quit's retval. - On error, returns
InterateResult::Err
containing error value.
fn run(&self) -> Option<i32>
[src]
Run unlimited iterations of the main loop object until the main loop's
quit
routine is called.
On success, returns Some
containing quit's retval. On error returns None
.
fn get_api(&self) -> &mut MainloopApi
[src]
Return the abstract main loop abstraction layer vtable for this main loop.
No need to free the API as it is owned by the loop and is destroyed when the loop is freed.
Talking to PA directly with C requires fetching this pointer explicitly via this function. This is actually unecessary through this binding. The pointer is retrieved automatically upon Mainloop creation, stored internally, and automatically obtained from it by functions that need it.
fn quit(&self, retval: i32)
[src]
Shutdown the main loop with the specified return value
fn wakeup(&self)
[src]
Interrupt a running poll (for threaded systems)
fn set_poll_func(&self, poll_cb: (PollFn, *mut c_void))
[src]
Change the poll() implementation
Trait Implementations
impl Mainloop for Mainloop
[src]
type MI = MainloopInner<MainloopInternal>
fn inner(&self) -> Rc<MainloopInner<MainloopInternal>>
[src]
fn new_io_event(
&self,
fd: i32,
events: IoEventFlagSet,
cb: (IoEventCb, *mut c_void)
) -> Option<IoEvent<Self::MI>>
[src]
&self,
fd: i32,
events: IoEventFlagSet,
cb: (IoEventCb, *mut c_void)
) -> Option<IoEvent<Self::MI>>
Create a new IO event
fn new_timer_event(
&self,
tv: &timeval,
cb: (TimeEventCb, *mut c_void)
) -> Option<TimeEvent<Self::MI>>
[src]
&self,
tv: &timeval,
cb: (TimeEventCb, *mut c_void)
) -> Option<TimeEvent<Self::MI>>
Create a new timer event
fn new_deferred_event(
&self,
cb: (DeferEventCb, *mut c_void)
) -> Option<DeferEvent<Self::MI>>
[src]
&self,
cb: (DeferEventCb, *mut c_void)
) -> Option<DeferEvent<Self::MI>>
Create a new deferred event
fn set_api_userdata(&self, userdata: *mut c_void)
[src]
Set the userdata pointer held in the api vtable object
fn get_api_userdata(&self) -> *mut c_void
[src]
Get the userdata pointer held in the api vtable object
fn quit(&self, retval: i32)
[src]
Call quit