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§
Source§impl Mainloop
impl Mainloop
Sourcepub fn new(context: Option<&mut MainContext>) -> Option<Self>
pub fn new(context: Option<&mut MainContext>) -> Option<Self>
Creates a new GLIB main loop object for the specified GLIB main loop context.
Takes an argument context
for the glib::MainContext
to use. If context is None
the
default context is used.
This returns the object in an Rc wrapper, allowing multiple references to be held, which allows event objects to hold one, thus ensuring they do not outlive it.
Sourcepub fn get_api<'a>(&self) -> &'a MainloopApi
pub fn get_api<'a>(&self) -> &'a MainloopApi
Gets 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.