pub struct Worker<T> { /* private fields */ }Expand description
Server worker.
A worker runs one service instance on its own arbiter thread. It receives items through an unbounded channel. Clones refer to the same worker.
Implementations§
Source§impl<T> Worker<T>
impl<T> Worker<T>
Sourcepub fn start<F>(name: String, cfg: F, cid: Option<CoreId>) -> Worker<T>where
T: Send + 'static,
F: ServerConfiguration<Item = T>,
pub fn start<F>(name: String, cfg: F, cid: Option<CoreId>) -> Worker<T>where
T: Send + 'static,
F: ServerConfiguration<Item = T>,
Starts a worker on a new arbiter thread.
Returns immediately. The worker reports
Unavailable until its service is
created. If cid is set, the worker thread is pinned to that core.
Sourcepub fn send(&self, msg: T) -> Result<(), T>
pub fn send(&self, msg: T) -> Result<(), T>
Sends a message to the worker.
Returns Ok if the message was queued. The message is queued even if
the worker is currently unavailable. Returns the message as Err if
the worker has stopped.
Sourcepub fn status(&self) -> WorkerStatus
pub fn status(&self) -> WorkerStatus
Returns the current worker status.
Sourcepub async fn wait_for_status(&mut self) -> WorkerStatus
pub async fn wait_for_status(&mut self) -> WorkerStatus
Waits for the next worker status change and returns the new status.
Returns immediately if the worker has failed.
Sourcepub fn stop(&self, timeout: Millis) -> WorkerStop ⓘ
pub fn stop(&self, timeout: Millis) -> WorkerStop ⓘ
Stops the worker.
The worker stops accepting items and shuts down its service, waiting
up to timeout. A zero timeout uses the default of 3 seconds.
Trait Implementations§
impl<T> Eq for Worker<T>
Source§impl<T> Ord for Worker<T>
impl<T> Ord for Worker<T>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Worker<T>
impl<T> !UnwindSafe for Worker<T>
impl<T> Freeze for Worker<T>
impl<T> Send for Worker<T>where
T: Send,
impl<T> Sync for Worker<T>where
T: Send,
impl<T> Unpin for Worker<T>
impl<T> UnsafeUnpin for Worker<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.