Struct pipewire::thread_loop::ThreadLoop
source · pub struct ThreadLoop { /* private fields */ }
Expand description
A wrapper around the pipewire threaded loop interface. ThreadLoops are a higher level of abstraction around the loop interface. A ThreadLoop can be used to spawn a new thread that runs the wrapped loop.
Implementations§
source§impl ThreadLoop
impl ThreadLoop
sourcepub unsafe fn new(
name: Option<&str>,
properties: Option<&DictRef>
) -> Result<Self, Error>
pub unsafe fn new( name: Option<&str>, properties: Option<&DictRef> ) -> Result<Self, Error>
Initialize Pipewire and create a new ThreadLoop
with the given name
and optional properties.
§Safety
TODO
sourcepub unsafe fn new_cstr(
name: Option<&CStr>,
properties: Option<&DictRef>
) -> Result<Self, Error>
pub unsafe fn new_cstr( name: Option<&CStr>, properties: Option<&DictRef> ) -> Result<Self, Error>
pub fn downgrade(&self) -> WeakThreadLoop
pub fn as_raw_ptr(&self) -> *mut pw_thread_loop
pub fn loop_(&self) -> &LoopRef
sourcepub fn lock(&self) -> ThreadLoopLockGuard<'_>
pub fn lock(&self) -> ThreadLoopLockGuard<'_>
Lock the Loop
This ensures that the loop thread will not access objects associated
with the loop while the lock is held, lock()
can be used multiple times
from the same thread.
The lock needs to be held whenever you call any PipeWire function that uses an object associated with this loop. Make sure to not hold on to the lock more than necessary though, as the threaded loop stops while the lock is held.
sourcepub fn wait(&self)
pub fn wait(&self)
Release the lock and wait
Release the lock and wait until some thread calls signal()
sourcepub fn timed_wait(&self, wait_max_sec: Duration)
pub fn timed_wait(&self, wait_max_sec: Duration)
Release the lock and wait a maximum of wait_max_sec
seconds
until some thread calls signal()
or time out
sourcepub fn get_time(&self, timeout: i64) -> TimeSpec
pub fn get_time(&self, timeout: i64) -> TimeSpec
Get a timespec suitable for timed_wait_full()
sourcepub fn timed_wait_full(&self, abstime: TimeSpec)
pub fn timed_wait_full(&self, abstime: TimeSpec)
Release the lock and wait up to abs seconds until some
thread calls signal()
. Use get_time()
to get a suitable timespec
Trait Implementations§
source§impl AsRef<LoopRef> for ThreadLoop
impl AsRef<LoopRef> for ThreadLoop
source§impl Clone for ThreadLoop
impl Clone for ThreadLoop
source§fn clone(&self) -> ThreadLoop
fn clone(&self) -> ThreadLoop
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more