Splits off a series of chunks from the end of the queue (the side with the newest jobs). Each chunk is of size `CHUNK_SIZE`. Afterwards, at most `CHUNK_SIZE` jobs will remain in the queue.
(&self)
| 184 | } |
| 185 | |
| 186 | /// The size of a chunk of jobs. |
| 187 | const CHUNK_SIZE: usize = 16; |
| 188 | |
| 189 | /// Splits off a series of chunks from the end of the queue (the side with |
| 190 | /// the newest jobs). Each chunk is of size `CHUNK_SIZE`. Afterwards, at most |
| 191 | /// `CHUNK_SIZE` jobs will remain in the queue. |
| 192 | pub fn split(&self) -> Vec<VecDeque<JobRef>> { |
| 193 | // SAFETY: We have unique access to `job_refs` (see the field |
| 194 | // invariant). |
| 195 | let job_refs = unsafe { &mut *self.job_refs.get() }; |
| 196 | let mut len = job_refs.len(); |
| 197 | let num_chunks = len / Self::CHUNK_SIZE; |
| 198 | (0..num_chunks) |
| 199 | .map(|_| { |
| 200 | let chunk = job_refs.split_off(len - Self::CHUNK_SIZE); |
| 201 | len -= Self::CHUNK_SIZE; |
| 202 | chunk |
| 203 | }) |
| 204 | .collect() |