pub struct CpuWorker { /* private fields */ }Expand description
A single-threaded background worker that executes closures in order.
ⓘ
let worker = CpuWorker::new();
worker.submit(|| {
save_checkpoint(&snapshot, "model.pt").unwrap();
});
// GPU training continues immediately
worker.finish(); // blocks until all queued work completesImplementations§
Source§impl CpuWorker
impl CpuWorker
Sourcepub fn submit<F: FnOnce() + Send + 'static>(&self, f: F)
pub fn submit<F: FnOnce() + Send + 'static>(&self, f: F)
Submit a closure to run on the background thread.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CpuWorker
impl !RefUnwindSafe for CpuWorker
impl Send for CpuWorker
impl Sync for CpuWorker
impl Unpin for CpuWorker
impl UnsafeUnpin for CpuWorker
impl !UnwindSafe for CpuWorker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more