MCPcopy Create free account
hub / github.com/NthTensor/Forte / split

Method split

src/job.rs:186–201  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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()

Callers 1

promote_coldMethod · 0.80

Calls 1

getMethod · 0.80

Tested by

no test coverage detected