diff --git a/actix-router/CHANGES.md b/actix-router/CHANGES.md index 581243fb..4c19aedc 100644 --- a/actix-router/CHANGES.md +++ b/actix-router/CHANGES.md @@ -1,6 +1,9 @@ # Changes ## Unreleased - 2021-xx-xx + + +## 0.2.7 - 2021-02-06 * Add `Router::recognize_checked` [#247] [#247]: https://github.com/actix/actix-net/pull/247 diff --git a/actix-router/Cargo.toml b/actix-router/Cargo.toml index 2446fc1b..f55c2c38 100644 --- a/actix-router/Cargo.toml +++ b/actix-router/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "actix-router" -version = "0.2.6" +version = "0.2.7" authors = ["Nikolay Kim "] description = "Resource path matching library" -keywords = ["actix"] +keywords = ["actix", "router", "routing"] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-net.git" documentation = "https://docs.rs/actix-router" diff --git a/actix-rt/CHANGES.md b/actix-rt/CHANGES.md index 15052613..6754ca33 100644 --- a/actix-rt/CHANGES.md +++ b/actix-rt/CHANGES.md @@ -3,6 +3,20 @@ ## Unreleased - 2021-xx-xx +## 2.0.2 - 2021-02-06 +* Add `Arbiter::handle` to get a handle of an owned Arbiter. [#274] +* Add `System::try_current` for situations where actix may or may not be running a System. [#275] + +[#274]: https://github.com/actix/actix-net/pull/274 +[#275]: https://github.com/actix/actix-net/pull/275 + + +## 2.0.1 - 2021-02-06 +* Expose `JoinError` from Tokio. [#271] + +[#271]: https://github.com/actix/actix-net/pull/271 + + ## 2.0.0 - 2021-02-02 * Remove all Arbiter-local storage methods. [#262] * Re-export `tokio::pin`. [#262] diff --git a/actix-rt/Cargo.toml b/actix-rt/Cargo.toml index db232090..7990e67d 100644 --- a/actix-rt/Cargo.toml +++ b/actix-rt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-rt" -version = "2.0.0" +version = "2.0.2" authors = [ "Nikolay Kim ", "Rob Ede ", diff --git a/actix-rt/src/arbiter.rs b/actix-rt/src/arbiter.rs index 7eae662a..9ff1419d 100644 --- a/actix-rt/src/arbiter.rs +++ b/actix-rt/src/arbiter.rs @@ -172,13 +172,18 @@ impl Arbiter { hnd } + /// Return a handle to the this Arbiter's message sender. + pub fn handle(&self) -> ArbiterHandle { + ArbiterHandle::new(self.tx.clone()) + } + /// Return a handle to the current thread's Arbiter's message sender. /// /// # Panics /// Panics if no Arbiter is running on the current thread. pub fn current() -> ArbiterHandle { HANDLE.with(|cell| match *cell.borrow() { - Some(ref addr) => addr.clone(), + Some(ref hnd) => hnd.clone(), None => panic!("Arbiter is not running."), }) } diff --git a/actix-rt/src/lib.rs b/actix-rt/src/lib.rs index 831958aa..a7e9f309 100644 --- a/actix-rt/src/lib.rs +++ b/actix-rt/src/lib.rs @@ -91,7 +91,7 @@ pub mod time { pub mod task { //! Task management (Tokio re-exports). - pub use tokio::task::{spawn_blocking, yield_now, JoinHandle}; + pub use tokio::task::{spawn_blocking, yield_now, JoinError, JoinHandle}; } /// Spawns a future on the current thread. diff --git a/actix-rt/src/system.rs b/actix-rt/src/system.rs index b7f134cb..3bc8a6e3 100644 --- a/actix-rt/src/system.rs +++ b/actix-rt/src/system.rs @@ -100,6 +100,15 @@ impl System { }) } + /// Try to get current running system. + /// + /// Returns `None` if no System has been started. + /// + /// Contrary to `current`, this never panics. + pub fn try_current() -> Option { + CURRENT.with(|cell| cell.borrow().clone()) + } + /// Get handle to a the System's initial [Arbiter]. pub fn arbiter(&self) -> &ArbiterHandle { &self.arbiter_handle diff --git a/actix-rt/tests/tests.rs b/actix-rt/tests/tests.rs index 56b5e8a6..86fba96d 100644 --- a/actix-rt/tests/tests.rs +++ b/actix-rt/tests/tests.rs @@ -122,6 +122,28 @@ fn arbiter_spawn_fn_runs() { arbiter.join().unwrap(); } +#[test] +fn arbiter_handle_spawn_fn_runs() { + let sys = System::new(); + + let (tx, rx) = channel::(); + + let arbiter = Arbiter::new(); + let handle = arbiter.handle(); + drop(arbiter); + + handle.spawn_fn(move || { + tx.send(42).unwrap(); + System::current().stop() + }); + + let num = rx.recv_timeout(Duration::from_secs(2)).unwrap(); + assert_eq!(num, 42); + + handle.stop(); + sys.run().unwrap(); +} + #[test] fn arbiter_drop_no_panic_fn() { let _ = System::new(); @@ -266,3 +288,13 @@ fn new_arbiter_with_tokio() { assert_eq!(false, counter.load(Ordering::SeqCst)); } + +#[test] +fn try_current_no_system() { + assert!(System::try_current().is_none()) +} + +#[test] +fn try_current_with_system() { + System::new().block_on(async { assert!(System::try_current().is_some()) }); +} diff --git a/actix-server/CHANGES.md b/actix-server/CHANGES.md index be59f125..5eca1f91 100644 --- a/actix-server/CHANGES.md +++ b/actix-server/CHANGES.md @@ -1,13 +1,18 @@ # Changes ## Unreleased - 2021-xx-xx + + +## 2.0.0-beta.3 - 2021-02-06 * Hidden `ServerBuilder::start` method has been removed. Use `ServerBuilder::run`. [#246] -* Add retry for EINTR(`io::Interrupted`) in `Accept`'s poll loop. [#264] -* Add `ServerBuilder::worker_max_blocking_threads` for customize blocking thread pool. [#265] +* Add retry for EINTR signal (`io::Interrupted`) in `Accept`'s poll loop. [#264] +* Add `ServerBuilder::worker_max_blocking_threads` to customize blocking thread pool size. [#265] +* Update `actix-rt` to `2.0.0`. [#273] [#246]: https://github.com/actix/actix-net/pull/246 [#264]: https://github.com/actix/actix-net/pull/264 [#265]: https://github.com/actix/actix-net/pull/265 +[#273]: https://github.com/actix/actix-net/pull/273 ## 2.0.0-beta.2 - 2021-01-03 diff --git a/actix-server/Cargo.toml b/actix-server/Cargo.toml index fdafb52a..1b088e30 100755 --- a/actix-server/Cargo.toml +++ b/actix-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-server" -version = "2.0.0-beta.2" +version = "2.0.0-beta.3" authors = [ "Nikolay Kim ", "fakeshadow <24548779@qq.com>", @@ -26,7 +26,7 @@ default = [] actix-codec = "0.4.0-beta.1" actix-rt = { version = "2.0.0", default-features = false } actix-service = "2.0.0-beta.4" -actix-utils = "3.0.0-beta.1" +actix-utils = "3.0.0-beta.2" futures-core = { version = "0.3.7", default-features = false, features = ["alloc"] } log = "0.4" diff --git a/actix-tls/CHANGES.md b/actix-tls/CHANGES.md index 11a1a410..a87f0fc5 100644 --- a/actix-tls/CHANGES.md +++ b/actix-tls/CHANGES.md @@ -1,17 +1,22 @@ # Changes ## Unreleased - 2021-xx-xx + + +## 3.0.0-beta.3 - 2021-02-06 * Remove `trust-dns-proto` and `trust-dns-resolver`. [#248] * Use `std::net::ToSocketAddrs` as simple and basic default resolver. [#248] -* Add `Resolve` trait for custom dns resolver. [#248] +* Add `Resolve` trait for custom DNS resolvers. [#248] * Add `Resolver::new_custom` function to construct custom resolvers. [#248] * Export `webpki_roots::TLS_SERVER_ROOTS` in `actix_tls::connect` mod and remove the export from `actix_tls::accept` [#248] * Remove `ConnectTakeAddrsIter`. `Connect::take_addrs` now returns `ConnectAddrsIter<'static>` as owned iterator. [#248] * Rename `Address::{host => hostname}` to more accurately describe which URL segment is returned. +* Update `actix-rt` to `2.0.0`. [#273] [#248]: https://github.com/actix/actix-net/pull/248 +[#273]: https://github.com/actix/actix-net/pull/273 ## 3.0.0-beta.2 - 2021-xx-xx diff --git a/actix-tls/Cargo.toml b/actix-tls/Cargo.toml index 09d47157..db79d6ab 100755 --- a/actix-tls/Cargo.toml +++ b/actix-tls/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-tls" -version = "3.0.0-beta.2" +version = "3.0.0-beta.3" authors = ["Nikolay Kim "] description = "TLS acceptor and connector services for Actix ecosystem" keywords = ["network", "tls", "ssl", "async", "transport"] @@ -43,7 +43,7 @@ uri = ["http"] actix-codec = "0.4.0-beta.1" actix-rt = { version = "2.0.0", default-features = false } actix-service = "2.0.0-beta.4" -actix-utils = "3.0.0-beta.1" +actix-utils = "3.0.0-beta.2" derive_more = "0.99.5" futures-core = { version = "0.3.7", default-features = false, features = ["alloc"] } @@ -64,7 +64,7 @@ tokio-native-tls = { version = "0.3", optional = true } [dev-dependencies] actix-rt = "2.0.0" -actix-server = "2.0.0-beta.2" +actix-server = "2.0.0-beta.3" bytes = "1" env_logger = "0.8" futures-util = { version = "0.3.7", default-features = false, features = ["sink"] } diff --git a/actix-utils/CHANGES.md b/actix-utils/CHANGES.md index 2504f012..a7871612 100644 --- a/actix-utils/CHANGES.md +++ b/actix-utils/CHANGES.md @@ -3,6 +3,12 @@ ## Unreleased - 2021-xx-xx +## 3.0.0-beta.2 - 2021-02-06 +* Update `actix-rt` to `2.0.0`. [#273] + +[#273]: https://github.com/actix/actix-net/pull/273 + + ## 3.0.0-beta.1 - 2020-12-28 * Update `bytes` dependency to `1`. [#237] * Use `pin-project-lite` to replace `pin-project`. [#229] diff --git a/actix-utils/Cargo.toml b/actix-utils/Cargo.toml index 4c1e6569..da46256e 100644 --- a/actix-utils/Cargo.toml +++ b/actix-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-utils" -version = "3.0.0-beta.1" +version = "3.0.0-beta.2" authors = ["Nikolay Kim "] description = "Various network related services and utilities for the Actix ecosystem" keywords = ["network", "framework", "async", "futures"] @@ -26,4 +26,5 @@ log = "0.4" pin-project-lite = "0.2.0" [dev-dependencies] +actix-rt = "2.0.0" futures-util = { version = "0.3.7", default-features = false } diff --git a/bytestring/Cargo.toml b/bytestring/Cargo.toml index 3e53417c..3dbf07b7 100644 --- a/bytestring/Cargo.toml +++ b/bytestring/Cargo.toml @@ -24,4 +24,4 @@ serde = { version = "1.0", optional = true } [dev-dependencies] serde_json = "1.0" -ahash = { version = "0.6", default-features = false } +ahash = { version = "0.7", default-features = false }