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

Method subscribe

flow-rs/src/broker.rs:51–68  ·  view source on GitHub ↗
(&mut self, topic: String)

Source from the content-addressed store, hash-verified

49 }
50
51 pub fn subscribe(&mut self, topic: String) -> BrokerClient {
52 let (notify, _, subs) = self.subs.entry(topic.clone()).or_insert_with(|| {
53 let (s, r) = unbounded();
54 (s, r, vec![])
55 });
56 let (s, r) = unbounded();
57 subs.push(s.clone());
58 self.count.fetch_add(1, Ordering::Relaxed);
59 BrokerClient {
60 id: subs.len() - 1,
61 notify: notify.clone(),
62 self_notify: s,
63 sub: r,
64 topic,
65 running: self.running.clone(),
66 count: self.count.clone(),
67 }
68 }
69
70 pub fn run(&mut self) -> JoinHandle<anyhow::Result<()>> {
71 self.running.store(true, Ordering::Relaxed);

Callers 2

newMethod · 0.80
loadMethod · 0.80

Calls 4

unboundedFunction · 0.85
pushMethod · 0.80
cloneMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected