Struct libpulse_binding::mainloop::threaded::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 threaded main loop object.
You have to call start
before the event loop thread starts running.
pub fn start(&mut self) -> Result<(), PAErr>
[src]
pub fn start(&mut self) -> Result<(), PAErr>
Start the event loop thread.
pub fn stop(&mut self)
[src]
pub fn stop(&mut self)
Terminate the event loop thread cleanly. Make sure to unlock the mainloop object before calling this function.
pub fn lock(&mut self)
[src]
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.
pub fn unlock(&mut self)
[src]
pub fn unlock(&mut self)
Unlock the event loop object, inverse of lock
.
pub fn wait(&mut self)
[src]
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!
pub fn signal(&mut self, wait_for_accept: bool)
[src]
pub fn signal(&mut self, wait_for_accept: bool)
Signal all threads waiting for a signalling event in wait
. If
wait_for_accept
is non-zero, do not return before the signal was accepted by an
accept
call. While waiting for that condition the event loop object is
unlocked.
pub fn accept(&mut self)
[src]
pub fn accept(&mut self)
Accept a signal from the event thread issued with signal
.
This call should only be used in conjunction with signal
with wait_for_accept
as
true
.
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 (used internally by
threaded mainloop).
pub fn get_api<'a>(&self) -> &'a mut MainloopApi
[src]
pub fn get_api<'a>(&self) -> &'a mut 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 unecessary 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 in_thread(&self) -> bool
[src]
pub fn in_thread(&self) -> bool
Returns true
when called from within the event loop thread.
pub fn set_name(&mut self, name: &str)
[src]
pub fn set_name(&mut self, name: &str)
Sets the name of the thread.
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,
cb: (IoEventCb, *mut c_void)
) -> Option<IoEvent<Self::MI>>
[src]
fn new_io_event(
&mut self,
fd: i32,
events: IoEventFlagSet,
cb: (IoEventCb, *mut c_void)
) -> Option<IoEvent<Self::MI>>
Create a new IO event
fn new_timer_event(
&mut self,
tv: &Timeval,
cb: (TimeEventCb, *mut c_void)
) -> Option<TimeEvent<Self::MI>>
[src]
fn new_timer_event(
&mut self,
tv: &Timeval,
cb: (TimeEventCb, *mut c_void)
) -> Option<TimeEvent<Self::MI>>
Create a new timer event
fn new_deferred_event(
&mut self,
cb: (DeferEventCb, *mut c_void)
) -> Option<DeferEvent<Self::MI>>
[src]
fn new_deferred_event(
&mut self,
cb: (DeferEventCb, *mut c_void)
) -> Option<DeferEvent<Self::MI>>
Create a new deferred event
fn set_api_userdata(&mut self, userdata: *mut c_void)
[src]
fn set_api_userdata(&mut self, userdata: *mut c_void)
Set the userdata pointer held in the api vtable object
fn get_api_userdata(&self) -> *mut c_void
[src]
fn get_api_userdata(&self) -> *mut c_void
Get the userdata pointer held in the api vtable object
fn quit(&mut self, retval: Retval)
[src]
fn quit(&mut self, retval: Retval)
Call quit