Struct ThreadLoopBox

Source
pub struct ThreadLoopBox { /* private fields */ }

Implementations§

Source§

impl ThreadLoopBox

Source

pub unsafe fn new( name: Option<&str>, properties: Option<&DictRef>, ) -> Result<Self, Error>

Initialize Pipewire and create a new ThreadLoopBox with the given name and optional properties.

§Safety

TODO

Source

pub unsafe fn new_cstr( name: Option<&CStr>, properties: Option<&DictRef>, ) -> Result<Self, Error>

Initialize Pipewire and create a new ThreadLoopBox with the given name as a C string, and optional properties.

§Safety

TODO

Source

pub unsafe fn from_raw(ptr: NonNull<pw_thread_loop>) -> Self

Create a new thread loop from a raw pw_thread_loop, taking ownership of it.

§Safety

The provided pointer must point to a valid, well aligned pw_thread_loop.

The raw loop should not be manually destroyed or moved, as the new ThreadLoopBox takes ownership of it.

Source

pub fn into_raw(self) -> NonNull<pw_thread_loop>

Methods from Deref<Target = ThreadLoop>§

Source

pub fn as_raw(&self) -> &pw_thread_loop

Source

pub fn as_raw_ptr(&self) -> *mut pw_thread_loop

Source

pub fn loop_(&self) -> &Loop

Source

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.

Source

pub fn start(&self)

Start the ThreadLoop

Source

pub fn stop(&self)

Stop the ThreadLoop

Stopping the ThreadLoop must be called without the lock

Source

pub fn signal(&self, signal: bool)

Signal all threads waiting with wait()

Source

pub fn wait(&self)

Release the lock and wait

Release the lock and wait until some thread calls signal()

Source

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

Source

pub fn get_time(&self, timeout: i64) -> TimeSpec

Get a timespec suitable for timed_wait_full()

Source

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

Source

pub fn accept(&self)

Signal all threads executing signal() with wait_for_accept

Source

pub fn in_thread(&self)

Check if inside the thread

Trait Implementations§

Source§

impl AsRef<ThreadLoop> for ThreadLoopBox

Source§

fn as_ref(&self) -> &ThreadLoop

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for ThreadLoopBox

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for ThreadLoopBox

Source§

type Target = ThreadLoop

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Drop for ThreadLoopBox

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.