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]
impl Mainloop
pub fn new() -> Option<Self>
[src]
pub fn new() -> Option<Self>
Allocate a new main loop object
pub fn prepare(&mut self, timeout: Option<i32>) -> Result<(), PAErr>
[src]
pub fn prepare(&mut self, timeout: Option<i32>) -> Result<(), PAErr>
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
.
pub fn poll(&mut self) -> Result<u32, PAErr>
[src]
pub fn poll(&mut self) -> Result<u32, PAErr>
Execute the previously prepared poll.
pub fn dispatch(&mut self) -> Result<u32, PAErr>
[src]
pub fn dispatch(&mut self) -> Result<u32, PAErr>
Dispatch timeout, IO and deferred events from the previously executed poll. On success returns the number of source dispatched.
pub fn get_retval(&self) -> Retval
[src]
pub fn get_retval(&self) -> Retval
Return the return value as specified with the main loop's quit
routine.
pub fn iterate(&mut self, block: bool) -> IterateResult
[src]
pub fn iterate(&mut self, block: bool) -> IterateResult
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 IterateResult
variant:
- On success, returns
IterateResult::Success
containing the number of sources dispatched in this iteration. - If exit was requested, returns
IterateResult::Quit
containing quit's retval. - On error, returns
IterateResult::Err
containing error value.
pub fn run(&mut self) -> Result<Retval, (PAErr, Retval)>
[src]
pub fn run(&mut self) -> Result<Retval, (PAErr, Retval)>
Run unlimited iterations of the main loop object until the main loop's
quit
routine is called.
On success, returns Ok
containing quit's return value. On error returns Err
containing a
tuple of the error value and quit's return value.
pub fn get_api<'a>(&self) -> &'a MainloopApi
[src]
pub fn get_api<'a>(&self) -> &'a MainloopApi
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 unnecessary through this binding. The pointer is retrieved automatically upon Mainloop creation, stored internally, and automatically obtained from it by functions that need it.
pub fn quit(&mut self, retval: Retval)
[src]
pub fn quit(&mut self, retval: Retval)
Shutdown the main loop with the specified return value
pub fn wakeup(&mut self)
[src]
pub fn wakeup(&mut self)
Interrupt a running poll (for threaded systems)
pub fn set_poll_func(&mut self, poll_cb: (PollFn, *mut c_void))
[src]
pub fn set_poll_func(&mut self, poll_cb: (PollFn, *mut c_void))
Change the poll() implementation
Trait Implementations
impl Mainloop for Mainloop
[src]
impl Mainloop for Mainloop
type MI = MainloopInner<MainloopInternal>
fn inner(&self) -> Rc<MainloopInner<MainloopInternal>>
[src]
fn inner(&self) -> Rc<MainloopInner<MainloopInternal>>
fn new_io_event(
&mut self,
fd: i32,
events: IoEventFlagSet,
callback: Box<FnMut(IoEventRef<Self::MI>, i32, IoEventFlagSet) + 'static>
) -> Option<IoEvent<Self::MI>>
[src]
fn new_io_event(
&mut self,
fd: i32,
events: IoEventFlagSet,
callback: Box<FnMut(IoEventRef<Self::MI>, i32, IoEventFlagSet) + 'static>
) -> Option<IoEvent<Self::MI>>
Create a new IO event Read more
fn new_timer_event(
&mut self,
tv: &UnixTs,
callback: Box<FnMut(TimeEventRef<Self::MI>) + 'static>
) -> Option<TimeEvent<Self::MI>>
[src]
fn new_timer_event(
&mut self,
tv: &UnixTs,
callback: Box<FnMut(TimeEventRef<Self::MI>) + 'static>
) -> Option<TimeEvent<Self::MI>>
Create a new timer event Read more
fn new_timer_event_rt(
&mut self,
t: MonotonicTs,
callback: Box<FnMut(TimeEventRef<Self::MI>) + 'static>
) -> Option<TimeEvent<Self::MI>>
[src]
fn new_timer_event_rt(
&mut self,
t: MonotonicTs,
callback: Box<FnMut(TimeEventRef<Self::MI>) + 'static>
) -> Option<TimeEvent<Self::MI>>
Create a new monotonic-based timer event Read more
fn new_deferred_event(
&mut self,
callback: Box<FnMut(DeferEventRef<Self::MI>) + 'static>
) -> Option<DeferEvent<Self::MI>>
[src]
fn new_deferred_event(
&mut self,
callback: Box<FnMut(DeferEventRef<Self::MI>) + 'static>
) -> Option<DeferEvent<Self::MI>>
Create a new deferred event Read more
fn once_event(&mut self, callback: Box<FnMut() + 'static>)
[src]
fn once_event(&mut self, callback: Box<FnMut() + 'static>)
Run the specified callback once from the main loop using an anonymous defer event. If the mainloop runs in a different thread, you need to follow the mainloop implementation's rules regarding how to safely create defer events. In particular, if you're using ::mainloop::threaded
, you must lock the mainloop before calling this function. Read more
fn quit(&mut self, retval: Retval)
[src]
fn quit(&mut self, retval: Retval)
Call quit
impl MainloopSignals for Mainloop
[src]
impl MainloopSignals for Mainloop
fn init_signals(&mut self) -> Result<(), PAErr>
[src]
fn init_signals(&mut self) -> Result<(), PAErr>
Initialize the UNIX signal subsystem and bind it to the specified main loop
fn signals_done(&self)
[src]
fn signals_done(&self)
Cleanup the signal subsystem