pub struct NetTransport { /* private fields */ }Expand description
Full-mesh TCP transport implementing both Transport (two-sided
send/recv) and SymmetricTransport (one-sided put/get/barrier).
Construct via TcpTransport::bind or ThunderboltTransport::bind.
Implementations§
Source§impl NetTransport
impl NetTransport
Sourcepub fn from_listener(
rank: u32,
world: u32,
listener: TcpListener,
peers: Vec<SocketAddr>,
heap_size: usize,
) -> Result<NetTransport, Error>
pub fn from_listener( rank: u32, world: u32, listener: TcpListener, peers: Vec<SocketAddr>, heap_size: usize, ) -> Result<NetTransport, Error>
Build a transport from an already-bound listener. Ranks above us
we connect to; ranks below us we accept from (each connector
announces itself with a HELLO). peers[r] is rank r’s listen
address; peers[rank] must match listener.
Public so callers (and multi-rank tests) can pre-bind ephemeral
ports, exchange the addresses out-of-band, then construct the
mesh — avoiding the fixed-port races TcpTransport::bind is
subject to.
Source§impl NetTransport
impl NetTransport
Sourcepub fn coordinator_listen(
world: u32,
listener: TcpListener,
heap_size: usize,
) -> Result<NetTransport, Error>
pub fn coordinator_listen( world: u32, listener: TcpListener, heap_size: usize, ) -> Result<NetTransport, Error>
Coordinator side of a star topology: bind listener (rank 0’s
address) and accept world - 1 worker connections, each announcing its
rank with a HELLO. Workers connect only to the coordinator (no
worker↔worker links), so a worker needs no inbound port — the
NAT/mobile-friendly shape for iOS, phones, and Pis behind a router.
Sourcepub fn worker_dial(
rank: u32,
world: u32,
coord_addr: SocketAddr,
heap_size: usize,
) -> Result<NetTransport, Error>
pub fn worker_dial( rank: u32, world: u32, coord_addr: SocketAddr, heap_size: usize, ) -> Result<NetTransport, Error>
Worker side of a star topology: dial the coordinator at coord_addr
and announce this rank. No listener — the worker only needs outbound
connectivity, so it works from behind NAT / on mobile.
Trait Implementations§
Source§impl Drop for NetTransport
impl Drop for NetTransport
Source§impl SymmetricTransport for NetTransport
impl SymmetricTransport for NetTransport
Source§fn put(&self, buf: SymmetricBuffer, src: &[u8]) -> Result<(), CollectiveError>
fn put(&self, buf: SymmetricBuffer, src: &[u8]) -> Result<(), CollectiveError>
src into buf. Errors on length mismatch.Source§fn get(
&self,
buf: SymmetricBuffer,
dst: &mut [u8],
) -> Result<(), CollectiveError>
fn get( &self, buf: SymmetricBuffer, dst: &mut [u8], ) -> Result<(), CollectiveError>
buf into dst. Errors on length mismatch.Source§impl Transport for NetTransport
impl Transport for NetTransport
Source§fn world_size(&self) -> u32
fn world_size(&self) -> u32
Source§fn send_bytes(
&self,
to: u32,
tag: u32,
bytes: &[u8],
) -> Result<(), CollectiveError>
fn send_bytes( &self, to: u32, tag: u32, bytes: &[u8], ) -> Result<(), CollectiveError>
bytes to rank to, tagged tag. Returns once the bytes
are handed to the transport (not necessarily delivered).Source§fn recv_bytes(&self, from: u32, tag: u32) -> Result<Vec<u8>, CollectiveError>
fn recv_bytes(&self, from: u32, tag: u32) -> Result<Vec<u8>, CollectiveError>
(from, tag) arrives, and
return its payload.Source§fn recv_bytes_timeout(
&self,
from: u32,
tag: u32,
timeout: Duration,
) -> Result<Option<Vec<u8>>, CollectiveError>
fn recv_bytes_timeout( &self, from: u32, tag: u32, timeout: Duration, ) -> Result<Option<Vec<u8>>, CollectiveError>
Self::recv_bytes but gives up after timeout, returning
Ok(None). The default blocks (transports with no deadline support
ignore the timeout); crate::NetTransport overrides it with a real
wait_timeout. This is the basis for not letting a slow or offline
edge node stall a collective (bounded staleness).Auto Trait Implementations§
impl !Freeze for NetTransport
impl RefUnwindSafe for NetTransport
impl Send for NetTransport
impl Sync for NetTransport
impl Unpin for NetTransport
impl UnsafeUnpin for NetTransport
impl UnwindSafe for NetTransport
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more