pub enum Layout {
Solo {
n_workers: usize,
},
Multihost {
hosts: Vec<Host>,
local_host_idx: usize,
},
}Expand description
How a circuit is laid out across one or more machines.
Variants§
Implementations§
Source§impl Layout
impl Layout
Sourcepub fn new_solo(n_workers: usize) -> Layout
pub fn new_solo(n_workers: usize) -> Layout
Returns a new solo layout with n_workers worker threads.
Sourcepub fn new_multihost(
params: &[(SocketAddr, usize)],
local_address: SocketAddr,
) -> Result<Layout, LayoutError>
pub fn new_multihost( params: &[(SocketAddr, usize)], local_address: SocketAddr, ) -> Result<Layout, LayoutError>
Returns a new multihost layout with as many hosts as specified in
params. Each tuple in params specifies a host’s unique network
address and the number of workers to run on that host. local_address
must be one of the addresses in params.
To execute such a multihost circuit, one must create a Runtime for it
on every host in params, passing the same params in each case. Each
host must pass its own local_address. The Runtime on each host
listens on its own address and connects to all the other addresses.
Sourcepub fn local_workers(&self) -> Range<usize> ⓘ
pub fn local_workers(&self) -> Range<usize> ⓘ
Returns the range of IDs for the workers on the local machine.
Sourcepub fn other_hosts(&self) -> impl Iterator<Item = &Host>
pub fn other_hosts(&self) -> impl Iterator<Item = &Host>
Returns an iterator over Hosts in this layout other than this one. If
this is a single-host layout, this will be an empty iterator.
Sourcepub fn all_hosts(&self) -> impl Iterator<Item = Range<usize>>
pub fn all_hosts(&self) -> impl Iterator<Item = Range<usize>>
Returns an iterator across the ranges of workers on all the hosts in this layout. A single-host layout will have a single range with all the workers, a two-host layout will have two ranges, and so on.
Sourcepub fn local_address(&self) -> Option<SocketAddr>
pub fn local_address(&self) -> Option<SocketAddr>
Returns the network address for the current machine, or None if this
is a solo layout.
pub fn is_multihost(&self) -> bool
pub fn is_solo(&self) -> bool
pub fn n_hosts(&self) -> usize
pub fn local_host_idx(&self) -> usize
Sourcepub fn worker_idx_to_host_idx(&self, worker_idx: usize) -> Option<usize>
pub fn worker_idx_to_host_idx(&self, worker_idx: usize) -> Option<usize>
Returns the host index corresponding to the given worker_idx.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Layout
impl<'de> Deserialize<'de> for Layout
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Layout
impl RefUnwindSafe for Layout
impl Send for Layout
impl Sync for Layout
impl Unpin for Layout
impl UnsafeUnpin for Layout
impl UnwindSafe for Layout
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<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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