MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / start

Method start

flow-rs/src/node/transform.rs:50–85  ·  view source on GitHub ↗
(
        mut self: Box<Self>,
        _: Context,
        _: ResourceCollection,
    )

Source from the content-addressed store, hash-verified

48
49impl Actor for DynOutTransform {
50 fn start(
51 mut self: Box<Self>,
52 _: Context,
53 _: ResourceCollection,
54 ) -> rt::task::JoinHandle<Result<()>> {
55 let (s, r) = rt::channel::unbounded();
56 rt::task::spawn(async move {
57 while let Ok((_, out)) = self.out.fetch().await {
58 let inp = self.inp.clone();
59 s.send(rt::task::spawn(async move {
60 let mut empty_n = 0;
61 loop {
62 while let Ok(msg) = inp.recv_any().await {
63 out.send_any(msg).await.ok();
64 }
65 if inp.is_closed() {
66 break;
67 }
68 let n = inp.empty_n();
69 for _ in empty_n..n {
70 out.send_any(DummyEnvelope {}.seal()).await.ok();
71 }
72 empty_n = n;
73 }
74 }))
75 .await
76 .ok();
77 }
78 });
79 rt::task::spawn(async move {
80 while let Ok(handle) = r.recv().await {
81 handle.await;
82 }
83 Ok(())
84 })
85 }
86}
87
88node_register!("DynOutTransform", DynOutTransform);

Callers

nothing calls this directly

Calls 10

unboundedFunction · 0.85
recv_anyMethod · 0.80
send_anyMethod · 0.80
sealMethod · 0.80
fetchMethod · 0.45
cloneMethod · 0.45
sendMethod · 0.45
is_closedMethod · 0.45
empty_nMethod · 0.45
recvMethod · 0.45

Tested by

no test coverage detected