From 7c5afc09a6f8f39e6b9461f42584501400607270 Mon Sep 17 00:00:00 2001
From: Nikolay Kim <fafhrd91@gmail.com>
Date: Thu, 28 Mar 2019 03:56:52 -0700
Subject: [PATCH] move threadpool to separate crate

---
 Cargo.toml                                    |  1 +
 actix-rt/CHANGES.md                           |  6 +++++
 actix-rt/Cargo.toml                           | 12 +++------
 actix-rt/src/lib.rs                           |  4 ++-
 actix-threadpool/CHANGES.md                   |  5 ++++
 actix-threadpool/Cargo.toml                   | 27 +++++++++++++++++++
 .../src/lib.rs                                |  4 +--
 7 files changed, 47 insertions(+), 12 deletions(-)
 create mode 100644 actix-threadpool/CHANGES.md
 create mode 100644 actix-threadpool/Cargo.toml
 rename actix-rt/src/blocking.rs => actix-threadpool/src/lib.rs (94%)

diff --git a/Cargo.toml b/Cargo.toml
index 2d83e705..3ff71a3d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,6 +22,7 @@ members = [
   "actix-server",
   "actix-server-config",
   "actix-test-server",
+  "actix-threadpool",
   "actix-utils",
   "router",
 ]
diff --git a/actix-rt/CHANGES.md b/actix-rt/CHANGES.md
index a0736672..47bb1dd0 100644
--- a/actix-rt/CHANGES.md
+++ b/actix-rt/CHANGES.md
@@ -1,5 +1,11 @@
 # Changes
 
+## [0.2.2] - 2019-03-28
+
+### Changed
+
+* Moved `blocking` module to `actix-threadpool` crate
+
 ## [0.2.1] - 2019-03-11
 
 ### Added
diff --git a/actix-rt/Cargo.toml b/actix-rt/Cargo.toml
index 9ab4db6d..1ba6947c 100644
--- a/actix-rt/Cargo.toml
+++ b/actix-rt/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "actix-rt"
-version = "0.2.1"
+version = "0.2.2"
 authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
 description = "Actix runtime"
 keywords = ["network", "framework", "async", "futures"]
@@ -11,21 +11,15 @@ categories = ["network-programming", "asynchronous"]
 license = "MIT/Apache-2.0"
 exclude = [".gitignore", ".travis.yml", ".cargo/config", "appveyor.yml"]
 edition = "2018"
-workspace = "../"
+workspace = ".."
 
 [lib]
 name = "actix_rt"
 path = "src/lib.rs"
 
 [dependencies]
-bytes = "0.4"
-derive_more = "0.14"
+actix-threadpool = { path="../actix-threadpool" }
 futures = "0.1.25"
-parking_lot = "0.7"
-lazy_static = "1.2"
-log = "0.4"
-num_cpus = "1.10"
-threadpool = "1.7"
 tokio-current-thread = "0.1"
 tokio-executor = "0.1.5"
 tokio-reactor = "0.1.7"
diff --git a/actix-rt/src/lib.rs b/actix-rt/src/lib.rs
index 2c585fb5..9b16b959 100644
--- a/actix-rt/src/lib.rs
+++ b/actix-rt/src/lib.rs
@@ -1,7 +1,6 @@
 //! A runtime implementation that runs everything on the current thread.
 
 mod arbiter;
-pub mod blocking;
 mod builder;
 mod runtime;
 mod system;
@@ -11,6 +10,9 @@ pub use self::builder::{Builder, SystemRunner};
 pub use self::runtime::Runtime;
 pub use self::system::System;
 
+#[doc(hidden)]
+pub use actix_threadpool as blocking;
+
 /// Spawns a future on the current arbiter.
 ///
 /// # Panics
diff --git a/actix-threadpool/CHANGES.md b/actix-threadpool/CHANGES.md
new file mode 100644
index 00000000..3ed0c39b
--- /dev/null
+++ b/actix-threadpool/CHANGES.md
@@ -0,0 +1,5 @@
+# Changes
+
+## [0.1.0] - 2019-03-28
+
+* Move threadpool to separate crate
diff --git a/actix-threadpool/Cargo.toml b/actix-threadpool/Cargo.toml
new file mode 100644
index 00000000..84438e12
--- /dev/null
+++ b/actix-threadpool/Cargo.toml
@@ -0,0 +1,27 @@
+[package]
+name = "actix-threadpool"
+version = "0.1.0"
+authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
+description = "Actix thread pool for sync code"
+keywords = ["actix", "network", "framework", "async", "futures"]
+homepage = "https://actix.rs"
+repository = "https://github.com/actix/actix-net.git"
+documentation = "https://docs.rs/actix-threadpool/"
+categories = ["network-programming", "asynchronous"]
+license = "MIT/Apache-2.0"
+exclude = [".gitignore", ".travis.yml", ".cargo/config", "appveyor.yml"]
+edition = "2018"
+workspace = ".."
+
+[lib]
+name = "actix_threadpool"
+path = "src/lib.rs"
+
+[dependencies]
+derive_more = "0.14"
+futures = "0.1.25"
+parking_lot = "0.7"
+lazy_static = "1.2"
+log = "0.4"
+num_cpus = "1.10"
+threadpool = "1.7"
diff --git a/actix-rt/src/blocking.rs b/actix-threadpool/src/lib.rs
similarity index 94%
rename from actix-rt/src/blocking.rs
rename to actix-threadpool/src/lib.rs
index e209a3e2..b9952e62 100644
--- a/actix-rt/src/blocking.rs
+++ b/actix-threadpool/src/lib.rs
@@ -9,7 +9,7 @@ use parking_lot::Mutex;
 use threadpool::ThreadPool;
 
 /// Env variable for default cpu pool size
-const ENV_CPU_POOL_VAR: &str = "ACTIX_CPU_POOL";
+const ENV_CPU_POOL_VAR: &str = "ACTIX_THREADPOOL";
 
 lazy_static::lazy_static! {
     pub(crate) static ref DEFAULT_POOL: Mutex<ThreadPool> = {
@@ -18,7 +18,7 @@ lazy_static::lazy_static! {
                 if let Ok(val) = val.parse() {
                     val
                 } else {
-                    log::error!("Can not parse ACTIX_CPU_POOL value");
+                    log::error!("Can not parse ACTIX_THREADPOOL value");
                     num_cpus::get() * 5
                 }
             }