Inline(never) more things for rqbit(bin) to compile faster
This commit is contained in:
parent
f42007f436
commit
34f3ec6c29
5 changed files with 72 additions and 47 deletions
|
|
@ -8,6 +8,7 @@ use std::collections::HashSet;
|
|||
use std::net::SocketAddr;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::pin::Pin;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
|
@ -15,6 +16,8 @@ use std::time::Duration;
|
|||
use anyhow::bail;
|
||||
use anyhow::Context;
|
||||
use buffers::ByteString;
|
||||
use futures::Future;
|
||||
use futures::FutureExt;
|
||||
use librqbit_core::hash_id::Id20;
|
||||
use librqbit_core::lengths::Lengths;
|
||||
use librqbit_core::peer_id::generate_peer_id;
|
||||
|
|
@ -395,23 +398,29 @@ impl ManagedTorrent {
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn wait_until_completed(&self) -> anyhow::Result<()> {
|
||||
// TODO: rewrite, this polling is horrible
|
||||
let live = loop {
|
||||
let live = self.with_state(|s| match s {
|
||||
ManagedTorrentState::Initializing(_) | ManagedTorrentState::Paused(_) => Ok(None),
|
||||
ManagedTorrentState::Live(l) => Ok(Some(l.clone())),
|
||||
ManagedTorrentState::Error(e) => bail!("{:?}", e),
|
||||
ManagedTorrentState::None => bail!("bug: torrent state is None"),
|
||||
})?;
|
||||
if let Some(live) = live {
|
||||
break live;
|
||||
}
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
};
|
||||
#[inline(never)]
|
||||
pub fn wait_until_completed(&self) -> Pin<Box<dyn Future<Output = anyhow::Result<()>> + '_>> {
|
||||
async move {
|
||||
// TODO: rewrite, this polling is horrible
|
||||
let live = loop {
|
||||
let live = self.with_state(|s| match s {
|
||||
ManagedTorrentState::Initializing(_) | ManagedTorrentState::Paused(_) => {
|
||||
Ok(None)
|
||||
}
|
||||
ManagedTorrentState::Live(l) => Ok(Some(l.clone())),
|
||||
ManagedTorrentState::Error(e) => bail!("{:?}", e),
|
||||
ManagedTorrentState::None => bail!("bug: torrent state is None"),
|
||||
})?;
|
||||
if let Some(live) = live {
|
||||
break live;
|
||||
}
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
};
|
||||
|
||||
live.wait_until_completed().await;
|
||||
Ok(())
|
||||
live.wait_until_completed().await;
|
||||
Ok(())
|
||||
}
|
||||
.boxed()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue