mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +02:00
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:
@@ -1,8 +1,6 @@
|
||||
use pool::Pool;
|
||||
use sender::Sender;
|
||||
|
||||
use std::sync::atomic::Ordering::{Acquire};
|
||||
|
||||
use futures::{Future, Poll, Async};
|
||||
#[cfg(feature = "unstable-futures")]
|
||||
use futures2;
|
||||
@@ -35,11 +33,10 @@ impl Future for Shutdown {
|
||||
|
||||
fn poll(&mut self) -> Poll<(), ()> {
|
||||
use futures::task;
|
||||
trace!("Shutdown::poll");
|
||||
|
||||
self.inner().shutdown_task.task1.register_task(task::current());
|
||||
|
||||
if 0 != self.inner().num_workers.load(Acquire) {
|
||||
if !self.inner().is_shutdown() {
|
||||
return Ok(Async::NotReady);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user