| 492 | pub 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 | |
| 501 | impl<'w, F> Scheduler<'w> for F |
| 502 | where |
| 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 | |
| 514 | pub 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 | /// |