Trait yatp::pool::Runner [−][src]
In the model of yatp, any piece of logic aiming to be executed in a thread
pool is called Task. There can be different definitions of Task. Some people
may choose Future
as Task, some may just want callbacks, or even Actor
messages. But no matter what a Task is, there should be some role know how
to execute it. The role is call Runner
.
The life cycle of a Runner is:
start
|
| <--- resume
| |
handle -> pause
|
end
Generally users should use the provided future thread pool or callback thread pool instead. This is only for advance customization.
Associated Types
Loading content...Required methods
fn handle(
&mut self,
local: &mut Local<Self::TaskCell>,
task_cell: Self::TaskCell
) -> bool
[src]
&mut self,
local: &mut Local<Self::TaskCell>,
task_cell: Self::TaskCell
) -> bool
Called when a task needs to be handled.
It’s possible that a task can’t be finished in a single execution, in which case feel free to spawn the task again and return false to indicate the task has not been finished yet.
Provided methods
fn start(&mut self, _local: &mut Local<Self::TaskCell>)
[src]
Called when the runner is started.
It’s guaranteed to be the first method to call before anything else.
fn pause(&mut self, _local: &mut Local<Self::TaskCell>) -> bool
[src]
Called when the runner is put to sleep.
fn resume(&mut self, _local: &mut Local<Self::TaskCell>)
[src]
Called when the runner is woken up.
fn end(&mut self, _local: &mut Local<Self::TaskCell>)
[src]
Called when the runner is about to be destroyed.
It’s guaranteed that no other method will be called after this method.
Implementors
impl Runner for yatp::task::callback::Runner
[src]
type TaskCell = TaskCell
fn handle(&mut self, local: &mut Local<TaskCell>, task_cell: TaskCell) -> bool
[src]
impl Runner for yatp::task::future::Runner
[src]
type TaskCell = TaskCell
fn handle(&mut self, local: &mut Local<TaskCell>, task_cell: TaskCell) -> bool
[src]
impl<R, T> Runner for MultilevelRunner<R> where
R: Runner<TaskCell = T>,
T: TaskCell,
[src]
R: Runner<TaskCell = T>,
T: TaskCell,