pub struct Completer { /* private fields */ }Expand description
A worker’s completion queue, for other threads to hand results back to a
connection that returned Step::Park.
§Examples
use net_io::{Input, Session, SessionContext, Step};
struct Slow;
impl Session for Slow {
fn on_data(&mut self, cx: &mut SessionContext<'_>, input: &mut Input) -> Step {
let n = input.bytes().len();
input.consume(n);
let (completer, id) = (cx.completer(), cx.info().id);
std::thread::spawn(move || {
let _ = completer.post(id, 1, 42);
});
Step::Park { until: None }
}
fn on_wake(&mut self, cx: &mut SessionContext<'_>, _token: u32, value: u64) -> Step {
let _ = cx.output().push(format!("{value}\n").as_bytes());
Step::Write
}
}Implementations§
Source§impl Completer
impl Completer
Sourcepub fn post(
&self,
connection: ConnectionId,
token: u32,
value: u64,
) -> Result<(), PostError>
pub fn post( &self, connection: ConnectionId, token: u32, value: u64, ) -> Result<(), PostError>
Posts a completion for connection. Never blocks.
§Errors
PostError::Full, PostError::WrongWorker, PostError::ServerStopped.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Completer
impl !UnwindSafe for Completer
impl Freeze for Completer
impl Send for Completer
impl Sync for Completer
impl Unpin for Completer
impl UnsafeUnpin for Completer
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
Mutably borrows from an owned value. Read more