summaryrefslogtreecommitdiffstats
path: root/tokio/src/runtime/blocking
diff options
context:
space:
mode:
authorAdam C. Foltzer <acfoltzer@acfoltzer.net>2020-05-07 16:24:24 -0700
committerGitHub <noreply@github.com>2020-05-07 16:24:24 -0700
commit07533a5255a6516b6e92c45e571a9ba497cb25d4 (patch)
tree3183522ed4b0fd921e48067c6f7b63a58f8e66c6 /tokio/src/runtime/blocking
parent4748b2571fc02d5ebbfe59e457f0e8d8ef0eb5f3 (diff)
rt: add Handle::spawn_blocking method (#2501)
This follows a similar pattern to `Handle::spawn` to add the blocking spawn capabilities to `Handle`.
Diffstat (limited to 'tokio/src/runtime/blocking')
-rw-r--r--tokio/src/runtime/blocking/mod.rs2
-rw-r--r--tokio/src/runtime/blocking/pool.rs2
-rw-r--r--tokio/src/runtime/blocking/schedule.rs2
-rw-r--r--tokio/src/runtime/blocking/task.rs4
4 files changed, 5 insertions, 5 deletions
diff --git a/tokio/src/runtime/blocking/mod.rs b/tokio/src/runtime/blocking/mod.rs
index 5c808335..0b36a75f 100644
--- a/tokio/src/runtime/blocking/mod.rs
+++ b/tokio/src/runtime/blocking/mod.rs
@@ -9,7 +9,7 @@ cfg_blocking_impl! {
mod schedule;
mod shutdown;
- mod task;
+ pub(crate) mod task;
use crate::runtime::Builder;
diff --git a/tokio/src/runtime/blocking/pool.rs b/tokio/src/runtime/blocking/pool.rs
index a3b208d1..40d417b1 100644
--- a/tokio/src/runtime/blocking/pool.rs
+++ b/tokio/src/runtime/blocking/pool.rs
@@ -148,7 +148,7 @@ impl fmt::Debug for BlockingPool {
// ===== impl Spawner =====
impl Spawner {
- fn spawn(&self, task: Task, rt: &Handle) -> Result<(), ()> {
+ pub(crate) fn spawn(&self, task: Task, rt: &Handle) -> Result<(), ()> {
let shutdown_tx = {
let mut shared = self.inner.shared.lock().unwrap();
diff --git a/tokio/src/runtime/blocking/schedule.rs b/tokio/src/runtime/blocking/schedule.rs
index e10778d5..4e044ab2 100644
--- a/tokio/src/runtime/blocking/schedule.rs
+++ b/tokio/src/runtime/blocking/schedule.rs
@@ -6,7 +6,7 @@ use crate::runtime::task::{self, Task};
///
/// We avoid storing the task by forgetting it in `bind` and re-materializing it
/// in `release.
-pub(super) struct NoopSchedule;
+pub(crate) struct NoopSchedule;
impl task::Schedule for NoopSchedule {
fn bind(_task: Task<Self>) -> NoopSchedule {
diff --git a/tokio/src/runtime/blocking/task.rs b/tokio/src/runtime/blocking/task.rs
index f98b8549..e0ae6e4e 100644
--- a/tokio/src/runtime/blocking/task.rs
+++ b/tokio/src/runtime/blocking/task.rs
@@ -3,13 +3,13 @@ use std::pin::Pin;
use std::task::{Context, Poll};
/// Converts a function to a future that completes on poll
-pub(super) struct BlockingTask<T> {
+pub(crate) struct BlockingTask<T> {
func: Option<T>,
}
impl<T> BlockingTask<T> {
/// Initializes a new blocking task from the given function
- pub(super) fn new(func: T) -> BlockingTask<T> {
+ pub(crate) fn new(func: T) -> BlockingTask<T> {
BlockingTask { func: Some(func) }
}
}