Skip to main content

WebPWorker

Struct WebPWorker 

Source
pub struct WebPWorker<D1, D2> { /* private fields */ }
Expand description

A worker that runs one hook on its job, on a thread or on the caller’s thread (C: WebPWorker).

Implementations§

Source§

impl<D1, D2> WebPWorker<D1, D2>

Source

pub fn init() -> Self

Creates an idle worker with no job and no thread (C: Init).

Source

pub fn set_job(&mut self, hook: WebPWorkerHook<D1, D2>, data1: D1, data2: D2)

Sets the hook and the data that the next launch or execute runs (C: setting hook, data1 and data2).

§Panics

Panics while the worker is working: C forbids the change until sync.

Source

pub fn job_data(&self) -> Option<(&D1, &D2)>

The data of the current job; None when there is no job or the worker is working, because the thread then owns the data.

Source

pub fn job_data_mut(&mut self) -> Option<(&mut D1, &mut D2)>

Mutable access to the data of the current job, under the same rule as WebPWorker::job_data.

Source

pub fn status(&self) -> WebPWorkerStatus

The current status (C: the status field).

Source

pub fn had_error(&self) -> bool

Whether the hook has failed since the last reset (C: the had_error field).

Source

pub fn execute(&mut self)

Runs the hook on the calling thread and records a failure (C: Execute). A worker without a job does nothing.

Source

pub fn launch(&mut self)

Starts the job on the thread (C: Launch). Without a thread nothing starts and the hook does not run, as in C.

Source

pub fn sync(&mut self) -> bool

Waits until the worker is idle, takes the job back and reports whether no hook has failed (C: Sync). Without a thread the job never left the worker, so this only reports the error flag.

Source

pub fn end(&mut self)

Stops the thread and takes the job back (C: End). A worker without a thread is left as it is.

Source§

impl<D1: Send + 'static, D2: Send + 'static> WebPWorker<D1, D2>

Source

pub fn reset(&mut self) -> bool

Starts the worker thread when the worker is idle, or syncs it when it is working. Clears the error flag first, as C does. Returns false when no thread can be started; the status then stays NOT_OK (C: Reset).

Trait Implementations§

Source§

impl<D1, D2> Default for WebPWorker<D1, D2>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<D1, D2> Drop for WebPWorker<D1, D2>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<D1, D2> !RefUnwindSafe for WebPWorker<D1, D2>

§

impl<D1, D2> !UnwindSafe for WebPWorker<D1, D2>

§

impl<D1, D2> Forget for WebPWorker<D1, D2>

§

impl<D1, D2> Freeze for WebPWorker<D1, D2>
where Option<Job<D1, D2>>: Freeze, Arc<Shared<D1, D2>>: Freeze,

§

impl<D1, D2> Move for WebPWorker<D1, D2>

§

impl<D1, D2> Send for WebPWorker<D1, D2>
where Option<Job<D1, D2>>: Send, Arc<Shared<D1, D2>>: Send,

§

impl<D1, D2> Sync for WebPWorker<D1, D2>
where Option<Job<D1, D2>>: Sync, Arc<Shared<D1, D2>>: Sync,

§

impl<D1, D2> Unpin for WebPWorker<D1, D2>
where Option<Job<D1, D2>>: Unpin, Arc<Shared<D1, D2>>: Unpin,

§

impl<D1, D2> UnsafeUnpin for WebPWorker<D1, D2>
where Option<Job<D1, D2>>: UnsafeUnpin, Arc<Shared<D1, D2>>: UnsafeUnpin,

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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.