Avoid hanging waiting for operations when buffer has none
This commit is contained in:
parent
75803d8dbb
commit
344d05045d
1 changed files with 9 additions and 6 deletions
|
@ -6255,16 +6255,19 @@ fn split_operations(
|
||||||
#[cfg(not(any(test, feature = "test-support")))]
|
#[cfg(not(any(test, feature = "test-support")))]
|
||||||
const CHUNK_SIZE: usize = 100;
|
const CHUNK_SIZE: usize = 100;
|
||||||
|
|
||||||
|
let mut done = false;
|
||||||
std::iter::from_fn(move || {
|
std::iter::from_fn(move || {
|
||||||
if operations.is_empty() {
|
if done {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(
|
let operations = operations
|
||||||
operations
|
.drain(..cmp::min(CHUNK_SIZE, operations.len()))
|
||||||
.drain(..cmp::min(CHUNK_SIZE, operations.len()))
|
.collect::<Vec<_>>();
|
||||||
.collect(),
|
if operations.is_empty() {
|
||||||
)
|
done = true;
|
||||||
|
}
|
||||||
|
Some(operations)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue