Skip to content

Commit 56e0056

Browse files
andrewjcgfacebook-github-bot
authored andcommitted
Expose more helpers on ActorMesh (#452)
Summary: Pull Request resolved: #452 Expose some additional helper methods off `ActorMeshRef`. In particular, `iter_actor_refs()` can be used by clients using `ActorConnection`s, as these, by definition, need to be established point-to-point. Reviewed By: mariusae Differential Revision: D77880648 fbshipit-source-id: 7691785f0cd6e1df2d1cb07f472081eb0cc59264
1 parent 865c1bd commit 56e0056

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

hyperactor_mesh/src/actor_mesh.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use hyperactor::Actor;
1515
use hyperactor::ActorId;
1616
use hyperactor::ActorRef;
1717
use hyperactor::Bind;
18+
use hyperactor::GangId;
19+
use hyperactor::GangRef;
1820
use hyperactor::Message;
1921
use hyperactor::Named;
2022
use hyperactor::PortHandle;
@@ -146,6 +148,13 @@ pub trait ActorMesh: Mesh {
146148
self.proc_mesh().world_id()
147149
}
148150

151+
/// Iterate over all `ActorRef<Self::Actor>` in this mesh.
152+
fn iter_actor_refs(&self) -> impl Iterator<Item = ActorRef<Self::Actor>> {
153+
let gang: GangRef<Self::Actor> =
154+
GangId(self.proc_mesh().world_id().clone(), self.name().to_string()).into();
155+
self.shape().slice().iter().map(move |rank| gang.rank(rank))
156+
}
157+
149158
/// Get a serializeable reference to this mesh similar to ActorHandle::bind
150159
fn bind(&self) -> ActorMeshRef<Self::Actor> {
151160
ActorMeshRef::attest(

0 commit comments

Comments
 (0)