mirror of https://github.com/fafhrd91/actix-net
prepare actix-rt v2.0.0 release
This commit is contained in:
parent
66bd5bf4a2
commit
b1f009de92
|
@ -3,6 +3,13 @@
|
||||||
## Unreleased - 2021-xx-xx
|
## Unreleased - 2021-xx-xx
|
||||||
|
|
||||||
|
|
||||||
|
## 2.0.0 - 2021-02-02
|
||||||
|
* Remove all Arbiter-local storage methods. [#???]
|
||||||
|
* Re-export `tokio::pin`. [#???]
|
||||||
|
|
||||||
|
[#???]: https://github.com/actix/actix-net/pull/???
|
||||||
|
|
||||||
|
|
||||||
## 2.0.0-beta.3 - 2021-01-31
|
## 2.0.0-beta.3 - 2021-01-31
|
||||||
* Remove `run_in_tokio`, `attach_to_tokio` and `AsyncSystemRunner`. [#253]
|
* Remove `run_in_tokio`, `attach_to_tokio` and `AsyncSystemRunner`. [#253]
|
||||||
* Return `JoinHandle` from `actix_rt::spawn`. [#253]
|
* Return `JoinHandle` from `actix_rt::spawn`. [#253]
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
[package]
|
[package]
|
||||||
name = "actix-rt"
|
name = "actix-rt"
|
||||||
version = "2.0.0-beta.3"
|
version = "2.0.0"
|
||||||
authors = [
|
authors = [
|
||||||
"Nikolay Kim <fafhrd91@gmail.com>",
|
"Nikolay Kim <fafhrd91@gmail.com>",
|
||||||
"Rob Ede <robjtede@icloud.com>",
|
"Rob Ede <robjtede@icloud.com>",
|
||||||
]
|
]
|
||||||
description = "Tokio-based single-threaded async runtime for the Actix ecosystem"
|
description = "Tokio-based single-threaded async runtime for the Actix ecosystem"
|
||||||
keywords = ["network", "framework", "async", "futures"]
|
keywords = ["async", "futures", "io", "runtime"]
|
||||||
homepage = "https://actix.rs"
|
homepage = "https://actix.rs"
|
||||||
repository = "https://github.com/actix/actix-net.git"
|
repository = "https://github.com/actix/actix-net.git"
|
||||||
documentation = "https://docs.rs/actix-rt"
|
documentation = "https://docs.rs/actix-rt"
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use std::{
|
use std::{
|
||||||
any::{Any, TypeId},
|
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
collections::HashMap,
|
|
||||||
fmt,
|
fmt,
|
||||||
future::Future,
|
future::Future,
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
|
@ -22,7 +20,6 @@ pub(crate) static COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
thread_local!(
|
thread_local!(
|
||||||
static HANDLE: RefCell<Option<ArbiterHandle>> = RefCell::new(None);
|
static HANDLE: RefCell<Option<ArbiterHandle>> = RefCell::new(None);
|
||||||
static STORAGE: RefCell<HashMap<TypeId, Box<dyn Any>>> = RefCell::new(HashMap::new());
|
|
||||||
);
|
);
|
||||||
|
|
||||||
pub(crate) enum ArbiterCommand {
|
pub(crate) enum ArbiterCommand {
|
||||||
|
@ -121,7 +118,6 @@ impl Arbiter {
|
||||||
|
|
||||||
System::set_current(sys);
|
System::set_current(sys);
|
||||||
|
|
||||||
STORAGE.with(|cell| cell.borrow_mut().clear());
|
|
||||||
HANDLE.with(|cell| *cell.borrow_mut() = Some(hnd.clone()));
|
HANDLE.with(|cell| *cell.borrow_mut() = Some(hnd.clone()));
|
||||||
|
|
||||||
// register arbiter
|
// register arbiter
|
||||||
|
@ -156,7 +152,6 @@ impl Arbiter {
|
||||||
let hnd = ArbiterHandle::new(tx);
|
let hnd = ArbiterHandle::new(tx);
|
||||||
|
|
||||||
HANDLE.with(|cell| *cell.borrow_mut() = Some(hnd.clone()));
|
HANDLE.with(|cell| *cell.borrow_mut() = Some(hnd.clone()));
|
||||||
STORAGE.with(|cell| cell.borrow_mut().clear());
|
|
||||||
|
|
||||||
local.spawn_local(ArbiterRunner { rx });
|
local.spawn_local(ArbiterRunner { rx });
|
||||||
|
|
||||||
|
@ -214,58 +209,6 @@ impl Arbiter {
|
||||||
pub fn join(self) -> thread::Result<()> {
|
pub fn join(self) -> thread::Result<()> {
|
||||||
self.thread_handle.join()
|
self.thread_handle.join()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Insert item into Arbiter's thread-local storage.
|
|
||||||
///
|
|
||||||
/// Overwrites any item of the same type previously inserted.
|
|
||||||
#[deprecated = "Will be removed in stable v2."]
|
|
||||||
pub fn set_item<T: 'static>(item: T) {
|
|
||||||
STORAGE.with(move |cell| cell.borrow_mut().insert(TypeId::of::<T>(), Box::new(item)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if Arbiter's thread-local storage contains an item type.
|
|
||||||
#[deprecated = "Will be removed in stable v2."]
|
|
||||||
pub fn contains_item<T: 'static>() -> bool {
|
|
||||||
STORAGE.with(move |cell| cell.borrow().contains_key(&TypeId::of::<T>()))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Call a function with a shared reference to an item in this Arbiter's thread-local storage.
|
|
||||||
///
|
|
||||||
/// # Panics
|
|
||||||
/// Panics if item is not in Arbiter's thread-local item storage.
|
|
||||||
#[deprecated = "Will be removed in stable v2."]
|
|
||||||
pub fn get_item<T: 'static, F, R>(mut f: F) -> R
|
|
||||||
where
|
|
||||||
F: FnMut(&T) -> R,
|
|
||||||
{
|
|
||||||
STORAGE.with(move |cell| {
|
|
||||||
let st = cell.borrow();
|
|
||||||
|
|
||||||
let type_id = TypeId::of::<T>();
|
|
||||||
let item = st.get(&type_id).and_then(downcast_ref).unwrap();
|
|
||||||
|
|
||||||
f(item)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Call a function with a mutable reference to an item in this Arbiter's thread-local storage.
|
|
||||||
///
|
|
||||||
/// # Panics
|
|
||||||
/// Panics if item is not in Arbiter's thread-local item storage.
|
|
||||||
#[deprecated = "Will be removed in stable v2."]
|
|
||||||
pub fn get_mut_item<T: 'static, F, R>(mut f: F) -> R
|
|
||||||
where
|
|
||||||
F: FnMut(&mut T) -> R,
|
|
||||||
{
|
|
||||||
STORAGE.with(move |cell| {
|
|
||||||
let mut st = cell.borrow_mut();
|
|
||||||
|
|
||||||
let type_id = TypeId::of::<T>();
|
|
||||||
let item = st.get_mut(&type_id).and_then(downcast_mut).unwrap();
|
|
||||||
|
|
||||||
f(item)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A persistent future that processes [Arbiter] commands.
|
/// A persistent future that processes [Arbiter] commands.
|
||||||
|
@ -296,11 +239,3 @@ impl Future for ArbiterRunner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn downcast_ref<T: 'static>(boxed: &Box<dyn Any>) -> Option<&T> {
|
|
||||||
boxed.downcast_ref()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn downcast_mut<T: 'static>(boxed: &mut Box<dyn Any>) -> Option<&mut T> {
|
|
||||||
boxed.downcast_mut()
|
|
||||||
}
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
//!
|
//!
|
||||||
//! The disadvantage is that idle threads will not steal work from very busy, stuck or otherwise
|
//! The disadvantage is that idle threads will not steal work from very busy, stuck or otherwise
|
||||||
//! backlogged threads. Tasks that are disproportionately expensive should be offloaded to the
|
//! backlogged threads. Tasks that are disproportionately expensive should be offloaded to the
|
||||||
//! blocking thread-pool using [`task::spawn_blocking`].
|
//! blocking task thread-pool using [`task::spawn_blocking`].
|
||||||
//!
|
//!
|
||||||
//! # Examples
|
//! # Examples
|
||||||
//! ```
|
//! ```
|
||||||
|
@ -56,6 +56,8 @@ pub use self::arbiter::{Arbiter, ArbiterHandle};
|
||||||
pub use self::runtime::Runtime;
|
pub use self::runtime::Runtime;
|
||||||
pub use self::system::{System, SystemRunner};
|
pub use self::system::{System, SystemRunner};
|
||||||
|
|
||||||
|
pub use tokio::pin;
|
||||||
|
|
||||||
pub mod signal {
|
pub mod signal {
|
||||||
//! Asynchronous signal handling (Tokio re-exports).
|
//! Asynchronous signal handling (Tokio re-exports).
|
||||||
|
|
||||||
|
|
|
@ -140,36 +140,6 @@ fn arbiter_drop_no_panic_fut() {
|
||||||
arbiter.join().unwrap();
|
arbiter.join().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[allow(deprecated)]
|
|
||||||
fn arbiter_item_storage() {
|
|
||||||
let _ = System::new();
|
|
||||||
|
|
||||||
let arbiter = Arbiter::new();
|
|
||||||
|
|
||||||
assert!(!Arbiter::contains_item::<u32>());
|
|
||||||
Arbiter::set_item(42u32);
|
|
||||||
assert!(Arbiter::contains_item::<u32>());
|
|
||||||
|
|
||||||
Arbiter::get_item(|&item: &u32| assert_eq!(item, 42));
|
|
||||||
Arbiter::get_mut_item(|&mut item: &mut u32| assert_eq!(item, 42));
|
|
||||||
|
|
||||||
let thread = thread::spawn(move || {
|
|
||||||
Arbiter::get_item(|&_item: &u32| unreachable!("u32 not in this thread"));
|
|
||||||
})
|
|
||||||
.join();
|
|
||||||
assert!(thread.is_err());
|
|
||||||
|
|
||||||
let thread = thread::spawn(move || {
|
|
||||||
Arbiter::get_mut_item(|&mut _item: &mut i8| unreachable!("i8 not in this thread"));
|
|
||||||
})
|
|
||||||
.join();
|
|
||||||
assert!(thread.is_err());
|
|
||||||
|
|
||||||
arbiter.stop();
|
|
||||||
arbiter.join().unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn no_system_current_panic() {
|
fn no_system_current_panic() {
|
||||||
|
|
|
@ -24,7 +24,7 @@ default = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-codec = "0.4.0-beta.1"
|
actix-codec = "0.4.0-beta.1"
|
||||||
actix-rt = { version = "2.0.0-beta.3", default-features = false }
|
actix-rt = { version = "2.0.0", default-features = false }
|
||||||
actix-service = "2.0.0-beta.3"
|
actix-service = "2.0.0-beta.3"
|
||||||
actix-utils = "3.0.0-beta.1"
|
actix-utils = "3.0.0-beta.1"
|
||||||
|
|
||||||
|
|
|
@ -24,5 +24,5 @@ futures-core = { version = "0.3.7", default-features = false }
|
||||||
pin-project-lite = "0.2"
|
pin-project-lite = "0.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "2.0.0-beta.3"
|
actix-rt = "2.0.0"
|
||||||
futures-util = { version = "0.3.7", default-features = false }
|
futures-util = { version = "0.3.7", default-features = false }
|
||||||
|
|
|
@ -41,7 +41,7 @@ uri = ["http"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-codec = "0.4.0-beta.1"
|
actix-codec = "0.4.0-beta.1"
|
||||||
actix-rt = { version = "2.0.0-beta.3", default-features = false }
|
actix-rt = { version = "2.0.0", default-features = false }
|
||||||
actix-service = "2.0.0-beta.3"
|
actix-service = "2.0.0-beta.3"
|
||||||
actix-utils = "3.0.0-beta.1"
|
actix-utils = "3.0.0-beta.1"
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ tls-native-tls = { package = "native-tls", version = "0.2", optional = true }
|
||||||
tokio-native-tls = { version = "0.3", optional = true }
|
tokio-native-tls = { version = "0.3", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "2.0.0-beta.3"
|
actix-rt = "2.0.0"
|
||||||
actix-server = "2.0.0-beta.2"
|
actix-server = "2.0.0-beta.2"
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
env_logger = "0.8"
|
env_logger = "0.8"
|
||||||
|
|
|
@ -23,5 +23,5 @@ tracing = "0.1"
|
||||||
tracing-futures = "0.2"
|
tracing-futures = "0.2"
|
||||||
|
|
||||||
[dev_dependencies]
|
[dev_dependencies]
|
||||||
actix-rt = "2.0.0-beta.3"
|
actix-rt = "2.0.0"
|
||||||
slab = "0.4"
|
slab = "0.4"
|
||||||
|
|
|
@ -17,7 +17,7 @@ path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-codec = "0.4.0-beta.1"
|
actix-codec = "0.4.0-beta.1"
|
||||||
actix-rt = { version = "2.0.0-beta.3", default-features = false }
|
actix-rt = { version = "2.0.0", default-features = false }
|
||||||
actix-service = "2.0.0-beta.3"
|
actix-service = "2.0.0-beta.3"
|
||||||
|
|
||||||
futures-core = { version = "0.3.7", default-features = false }
|
futures-core = { version = "0.3.7", default-features = false }
|
||||||
|
|
Loading…
Reference in New Issue