Struct libpulse_binding::mainloop::threaded::Mainloop
source · pub struct Mainloop {
pub _inner: Rc<MainloopInner<MainloopInternal>>,
}
Expand description
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
Implementations
sourceimpl Mainloop
impl Mainloop
sourcepub fn new() -> Option<Self>
pub fn new() -> Option<Self>
Allocate a new threaded main loop object.
You have to call start
before the event loop thread starts running.
sourcepub fn stop(&mut self)
pub fn stop(&mut self)
Terminate the event loop thread cleanly. Make sure to unlock the mainloop object before calling this function.
sourcepub fn lock(&mut self)
pub fn lock(&mut self)
Lock the event loop object, effectively blocking the event loop thread from processing events. You can use this to enforce exclusive access to all objects attached to the event loop. This lock is recursive. This function may not be called inside the event loop thread. Events that are dispatched from the event loop thread are executed with this lock held.
sourcepub fn wait(&mut self)
pub fn wait(&mut self)
Wait for an event to be signalled by the event loop thread. You can use this to pass data
from the event loop thread to the main thread in a synchronized fashion. This function may
not be called inside the event loop thread. Prior to this call the event loop object needs
to be locked using lock
. While waiting the lock will be released.
Immediately before returning it will be acquired again. This function may spuriously wake up
even without signal
being called. You need to make sure to handle that!
sourcepub fn get_retval(&self) -> Retval
pub fn get_retval(&self) -> Retval
Return the return value as specified with the main loop’s quit
routine (used internally by
threaded mainloop).
sourcepub fn get_api<'a>(&self) -> &'a MainloopApi
pub fn get_api<'a>(&self) -> &'a MainloopApi
Return the main loop abstraction layer vtable for this main loop.
There is no need to free this object 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.
Trait Implementations
sourceimpl Mainloop for Mainloop
impl Mainloop for Mainloop
type MI = MainloopInner<pa_threaded_mainloop>
fn inner(&self) -> Rc<MainloopInner<MainloopInternal>>
sourcefn new_io_event(
&mut self,
fd: i32,
events: IoEventFlagSet,
callback: Box<dyn FnMut(IoEventRef<Self::MI>, i32, IoEventFlagSet) + 'static>
) -> Option<IoEvent<Self::MI>>
fn new_io_event(
&mut self,
fd: i32,
events: IoEventFlagSet,
callback: Box<dyn FnMut(IoEventRef<Self::MI>, i32, IoEventFlagSet) + 'static>
) -> Option<IoEvent<Self::MI>>
sourcefn new_timer_event(
&mut self,
tv: &UnixTs,
callback: Box<dyn FnMut(TimeEventRef<Self::MI>) + 'static>
) -> Option<TimeEvent<Self::MI>>
fn new_timer_event(
&mut self,
tv: &UnixTs,
callback: Box<dyn FnMut(TimeEventRef<Self::MI>) + 'static>
) -> Option<TimeEvent<Self::MI>>
sourcefn new_timer_event_rt(
&mut self,
t: MonotonicTs,
callback: Box<dyn FnMut(TimeEventRef<Self::MI>) + 'static>
) -> Option<TimeEvent<Self::MI>>
fn new_timer_event_rt(
&mut self,
t: MonotonicTs,
callback: Box<dyn FnMut(TimeEventRef<Self::MI>) + 'static>
) -> Option<TimeEvent<Self::MI>>
sourcefn new_deferred_event(
&mut self,
callback: Box<dyn FnMut(DeferEventRef<Self::MI>) + 'static>
) -> Option<DeferEvent<Self::MI>>
fn new_deferred_event(
&mut self,
callback: Box<dyn FnMut(DeferEventRef<Self::MI>) + 'static>
) -> Option<DeferEvent<Self::MI>>
sourcefn once_event(&mut self, callback: Box<dyn FnMut() + 'static>)
fn once_event(&mut self, callback: Box<dyn FnMut() + 'static>)
::mainloop::threaded
, you must lock the mainloop before calling
this function. Read more