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T6G2V5WUFYLWTCEVVEI2EZHGM6XYRAC
WTZXEWY7IAXJAFNV7STCNQY2SNRDPHX3MKOEZ77NEJUN4MS2VYSQC
while let Some(c) = hashes.recv().await {
debug!("downloading {:?}", c);
let t = std::mem::replace(
&mut pool[cur],
Some(tokio::spawn(download_change(
self.client.clone(),
self.url.clone(),
self.headers.clone(),
path.clone(),
c,
))),
);
if let Some(t) = t {
loop {
if let Some(t) = pool[cur].take() {
cur = (cur + 1) % POOL_SIZE;
}
for f in 0..POOL_SIZE {
if let Some(t) = pool[(cur + f) % POOL_SIZE].take() {
let c = t.await??;
debug!("sending {:?}", c);
super::PROGRESS.borrow_mut().unwrap()[pro_n].incr();
if send.send((c, true)).await.is_err() {
debug!("err for {:?}", c);
if next == cur {
if let Some(c) = hashes.recv().await {
debug!("downloading on process {:?}: {:?}", cur, c);
pool[cur] = Some(tokio::spawn(download_change(
self.client.clone(),
self.url.clone(),
self.headers.clone(),
path.clone(),
c,
)));
cur = (cur + 1) % POOL_SIZE;
} else {
debug!("sent");
} else {
tokio::select! {
c = hashes.recv() => {
if let Some(c) = c {
debug!("downloading on process {:?}: {:?}", cur, c);
pool[cur] = Some(tokio::spawn(download_change(
self.client.clone(),
self.url.clone(),
self.headers.clone(),
path.clone(),
c,
)));
cur = (cur + 1) % POOL_SIZE;
} else {
break;
}
}
c = pool[next].as_mut().unwrap() => {
pool[next] = None;
let c = c??;
super::PROGRESS.borrow_mut().unwrap()[pro_n].incr();
if send.send((c, true)).await.is_err() {
debug!("err for {:?}", c);
break;
}
}
}