Struct glommio::net::AcceptedUnixStream [−][src]
pub struct AcceptedUnixStream { /* fields omitted */ }
Expand description
An Accepted Unix connection that can be moved to a different executor
This is useful in situations where the load balancing provided by the
Operating System through ReusePort is not desirable. The user can accept the
connection in one executor through shared_accept
which returns an
AcceptedUnixStream.
Once the AcceptedUnixStream
arrives at its destination it can then be made
active with bind_to_executor
Implementations
Binds this AcceptedUnixStream
to the current executor
This returns a UnixStream
that can then be used normally
Examples
use glommio::{
channels::shared_channel,
net::UnixListener,
LocalExecutor,
LocalExecutorBuilder,
};
let ex = LocalExecutor::default();
ex.run(async move {
let (sender, receiver) = shared_channel::new_bounded(1);
let sender = sender.connect().await;
let listener = UnixListener::bind("/tmp/named").unwrap();
let accepted = listener.shared_accept().await.unwrap();
sender.try_send(accepted).unwrap();
let ex1 = LocalExecutorBuilder::new()
.spawn(move || async move {
let receiver = receiver.connect().await;
let accepted = receiver.recv().await.unwrap();
let _ = accepted.bind_to_executor();
})
.unwrap();
ex1.join().unwrap();
});
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for AcceptedUnixStream
impl Send for AcceptedUnixStream
impl Sync for AcceptedUnixStream
impl Unpin for AcceptedUnixStream
impl UnwindSafe for AcceptedUnixStream
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more