Threadpool blocking (#317)

This patch adds a `blocking` to `tokio-threadpool`. This function serves
as a way to annotate sections of code that will perform blocking
operations. This informs the thread pool that an additional thread needs
to be spawned to replace the current thread, which will no longer be
able to process the work queue.
This commit is contained in:
Carl Lerche
2018-04-15 12:29:22 -07:00
committed by GitHub
parent 372400ed34
commit 61d635e8ad
26 changed files with 2794 additions and 286 deletions
+3 -5
View File
@@ -137,7 +137,7 @@ impl WorkerEntry {
/// Returns `Ok` when the worker was successfully signaled.
///
/// Returns `Err` if the worker has already terminated.
pub fn signal_stop(&self, mut state: State) -> Result<(), ()> {
pub fn signal_stop(&self, mut state: State) {
use worker::Lifecycle::*;
// Transition the worker state to signaled
@@ -146,7 +146,7 @@ impl WorkerEntry {
match state.lifecycle() {
Shutdown => {
return Err(());
return;
}
Running | Sleeping => {}
Notified | Signaled => {
@@ -161,7 +161,7 @@ impl WorkerEntry {
// b) The shutdown signal is stored as the head of the
// sleep, stack which will prevent the worker from going to
// sleep again.
return Ok(());
return;
}
}
@@ -179,8 +179,6 @@ impl WorkerEntry {
// Wakeup the worker
self.wakeup();
Ok(())
}
/// Pop a task