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

Method spawn

src/thread_pool.rs:494–518  ·  view source on GitHub ↗
(self, scheduler: S, worker: Option<&Worker>)

Source from the content-addressed store, hash-verified

492pub trait Scheduler<'w>: Send + Sync {
493 /// Queues a job ref.
494 ///
495 /// This is passed the job ref that should be queued, and the outcome of
496 /// `Worker::with_current` in the current context. The worker parameter does
497 /// not have to be used, it is simply provided to avoid a lookup.
498 fn schedule(&self, job_ref: JobRef, worker: Option<&'w Worker>);
499}
500
501impl<'w, F> Scheduler<'w> for F
502where
503 F: Fn(JobRef, Option<&'w Worker>) + Send + Sync,
504{
505 #[inline(always)]
506 fn schedule(&self, job_ref: JobRef, worker: Option<&'w Worker>) {
507 self(job_ref, worker);
508 }
509}
510
511// -----------------------------------------------------------------------------
512// Spawn Trait
513
514pub use async_task::Task;
515
516/// A trait for types that can be spawned onto a [`ThreadPool`].
517///
518/// This trait is sealed and cannot be implemented outside of forte.
519///
520/// It is implemented for:
521///

Callers 6

resizeMethod · 0.45
spawn_onMethod · 0.45
spawn_localMethod · 0.45
spawnFunction · 0.45
spawn_cancel_safetyFunction · 0.45

Calls 4

push_newMethod · 0.80
push_shared_jobMethod · 0.80
into_job_refMethod · 0.45
scheduleMethod · 0.45

Tested by 2

spawn_cancel_safetyFunction · 0.36