2020-08-29 19:35:41 +00:00
|
|
|
//! Definitions for a few common task pools that we want. Generally the determining factor for what
|
|
|
|
//! kind of work should go in each pool is latency requirements.
|
|
|
|
//!
|
2021-12-29 17:38:13 +00:00
|
|
|
//! For CPU-intensive work (tasks that generally spin until completion) we have a standard
|
|
|
|
//! [`ComputeTaskPool`] and an [`AsyncComputeTaskPool`]. Work that does not need to be completed to
|
|
|
|
//! present the next frame should go to the [`AsyncComputeTaskPool`]
|
2020-08-29 19:35:41 +00:00
|
|
|
//!
|
|
|
|
//! For IO-intensive work (tasks that spend very little time in a "woken" state) we have an IO
|
|
|
|
//! task pool. The tasks here are expected to complete very quickly. Generally they should just
|
|
|
|
//! await receiving data from somewhere (i.e. disk) and signal other systems when the data is ready
|
|
|
|
//! for consumption. (likely via channels)
|
|
|
|
|
|
|
|
use super::TaskPool;
|
|
|
|
use std::ops::Deref;
|
|
|
|
|
|
|
|
/// A newtype for a task pool for CPU-intensive work that must be completed to deliver the next
|
|
|
|
/// frame
|
2020-10-08 18:43:01 +00:00
|
|
|
#[derive(Clone, Debug)]
|
2020-08-29 19:35:41 +00:00
|
|
|
pub struct ComputeTaskPool(pub TaskPool);
|
|
|
|
|
|
|
|
impl Deref for ComputeTaskPool {
|
|
|
|
type Target = TaskPool;
|
|
|
|
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
&self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// A newtype for a task pool for CPU-intensive work that may span across multiple frames
|
2020-10-08 18:43:01 +00:00
|
|
|
#[derive(Clone, Debug)]
|
2020-08-29 19:35:41 +00:00
|
|
|
pub struct AsyncComputeTaskPool(pub TaskPool);
|
|
|
|
|
|
|
|
impl Deref for AsyncComputeTaskPool {
|
|
|
|
type Target = TaskPool;
|
|
|
|
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
&self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// A newtype for a task pool for IO-intensive work (i.e. tasks that spend very little time in a
|
|
|
|
/// "woken" state)
|
2020-10-08 18:43:01 +00:00
|
|
|
#[derive(Clone, Debug)]
|
2020-09-22 03:23:09 +00:00
|
|
|
pub struct IoTaskPool(pub TaskPool);
|
2020-08-29 19:35:41 +00:00
|
|
|
|
2020-09-22 03:23:09 +00:00
|
|
|
impl Deref for IoTaskPool {
|
2020-08-29 19:35:41 +00:00
|
|
|
type Target = TaskPool;
|
|
|
|
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
&self.0
|
|
|
|
}
|
|
|
|
}
|