pub trait ScopedCpuJobs: Sync {
// Required methods
fn len(&self) -> usize;
fn run(&self, index: usize) -> Result<(), CpuDomainExecutorError>;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
Synchronously submitted indexed jobs for engine-owned outer scheduling.
Implementations expose a borrowed logical range 0..len() without
allocating a job collection. Every indexed call must finish before
CpuDomainExecutor::submit returns.
§Examples
use tenferro_cpu::{CpuDomainExecutorError, ScopedCpuJobs};
struct Jobs;
impl ScopedCpuJobs for Jobs {
fn len(&self) -> usize { 2 }
fn run(&self, index: usize) -> Result<(), CpuDomainExecutorError> {
assert!(index < self.len());
Ok(())
}
}
let jobs: &dyn ScopedCpuJobs = &Jobs;
assert_eq!(jobs.len(), 2);
jobs.run(1).unwrap();Required Methods§
Sourcefn len(&self) -> usize
fn len(&self) -> usize
Return the number of indexed jobs in this synchronous submission.
§Examples
use tenferro_cpu::{CpuDomainExecutorError, ScopedCpuJobs};
struct Jobs;
impl ScopedCpuJobs for Jobs {
fn len(&self) -> usize { 3 }
fn run(&self, _index: usize) -> Result<(), CpuDomainExecutorError> { Ok(()) }
}
assert_eq!(Jobs.len(), 3);Sourcefn run(&self, index: usize) -> Result<(), CpuDomainExecutorError>
fn run(&self, index: usize) -> Result<(), CpuDomainExecutorError>
Run one indexed job synchronously.
§Examples
use tenferro_cpu::{CpuDomainExecutorError, ScopedCpuJobs};
struct Jobs;
impl ScopedCpuJobs for Jobs {
fn len(&self) -> usize { 1 }
fn run(&self, index: usize) -> Result<(), CpuDomainExecutorError> {
assert_eq!(index, 0);
Ok(())
}
}
Jobs.run(0).unwrap();§Errors
Returns CpuDomainExecutorError::Admission,
CpuDomainExecutorError::Scheduling,
CpuDomainExecutorError::Cancellation, or
CpuDomainExecutorError::PanicBridge when that failure is observed
while running the indexed job.
Provided Methods§
Sourcefn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Return whether this submission contains no indexed jobs.
§Examples
use tenferro_cpu::{CpuDomainExecutorError, ScopedCpuJobs};
struct Jobs;
impl ScopedCpuJobs for Jobs {
fn len(&self) -> usize { 0 }
fn run(&self, _index: usize) -> Result<(), CpuDomainExecutorError> { Ok(()) }
}
assert!(Jobs.is_empty());