Avoid holding strong handle to Channel in long-lived task
This commit is contained in:
parent
5a4ba7f551
commit
680b86b17c
1 changed files with 4 additions and 3 deletions
|
@ -88,12 +88,12 @@ impl ChannelList {
|
||||||
rpc: Arc<rpc::Client>,
|
rpc: Arc<rpc::Client>,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let _task = cx.spawn(|this, mut cx| {
|
let _task = cx.spawn_weak(|this, mut cx| {
|
||||||
let rpc = rpc.clone();
|
let rpc = rpc.clone();
|
||||||
async move {
|
async move {
|
||||||
let mut status = rpc.status();
|
let mut status = rpc.status();
|
||||||
loop {
|
while let Some((status, this)) = status.recv().await.zip(this.upgrade(&cx)) {
|
||||||
match status.recv().await.unwrap() {
|
match status {
|
||||||
rpc::Status::Connected { .. } => {
|
rpc::Status::Connected { .. } => {
|
||||||
let response = rpc
|
let response = rpc
|
||||||
.request(proto::GetChannels {})
|
.request(proto::GetChannels {})
|
||||||
|
@ -128,6 +128,7 @@ impl ChannelList {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
.log_err()
|
.log_err()
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue