mirror of https://github.com/fafhrd91/actix-net
tweak changelog
This commit is contained in:
parent
931690d387
commit
5db9ba69a8
|
@ -1,7 +1,7 @@
|
|||
# Changes
|
||||
|
||||
## Unreleased - 2021-xx-xx
|
||||
* Add `io-uring` feature for enabling async file Io on linux system. [#374]
|
||||
* Add `io-uring` feature for enabling async file I/O on linux. [#374]
|
||||
* The `spawn` method can now resolve with non-unit outputs. [#369]
|
||||
|
||||
[#369]: https://github.com/actix/actix-net/pull/369
|
||||
|
|
|
@ -29,7 +29,7 @@ actix-macros = { version = "0.2.0", optional = true }
|
|||
futures-core = { version = "0.3", default-features = false }
|
||||
tokio = { version = "1.3", features = ["rt", "net", "parking_lot", "signal", "sync", "time"] }
|
||||
|
||||
[target."cfg(target_os = \"linux\")".dependencies]
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
tokio-uring = { version = "0.1", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -91,11 +91,11 @@ pub struct Arbiter {
|
|||
}
|
||||
|
||||
impl Arbiter {
|
||||
#[cfg(any(not(target_os = "linux"), not(feature = "io-uring")))]
|
||||
/// Spawn a new Arbiter thread and start its event loop.
|
||||
///
|
||||
/// # Panics
|
||||
/// Panics if a [System] is not registered on the current thread.
|
||||
#[cfg(any(not(target_os = "linux"), not(feature = "io-uring")))]
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> Arbiter {
|
||||
Self::with_tokio_rt(|| {
|
||||
|
@ -104,10 +104,10 @@ impl Arbiter {
|
|||
})
|
||||
}
|
||||
|
||||
#[cfg(any(not(target_os = "linux"), not(feature = "io-uring")))]
|
||||
/// Spawn a new Arbiter using the [Tokio Runtime](tokio-runtime) returned from a closure.
|
||||
///
|
||||
/// [tokio-runtime]: tokio::runtime::Runtime
|
||||
#[cfg(any(not(target_os = "linux"), not(feature = "io-uring")))]
|
||||
#[doc(hidden)]
|
||||
pub fn with_tokio_rt<F>(runtime_factory: F) -> Arbiter
|
||||
where
|
||||
|
@ -159,11 +159,11 @@ impl Arbiter {
|
|||
Arbiter { tx, thread_handle }
|
||||
}
|
||||
|
||||
#[cfg(all(target_os = "linux", feature = "io-uring"))]
|
||||
/// Spawn a new Arbiter thread and start its event loop with `tokio-uring` runtime.
|
||||
///
|
||||
/// # Panics
|
||||
/// Panics if a [System] is not registered on the current thread.
|
||||
#[cfg(all(target_os = "linux", feature = "io-uring"))]
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> Arbiter {
|
||||
let sys = System::current();
|
||||
|
@ -211,7 +211,7 @@ impl Arbiter {
|
|||
Arbiter { tx, thread_handle }
|
||||
}
|
||||
|
||||
/// Sets up an Arbiter runner in a new System using the provided runtime local task set.
|
||||
/// Sets up an Arbiter runner in a new System using the environment's local set.
|
||||
pub(crate) fn in_new_system() -> ArbiterHandle {
|
||||
let (tx, rx) = mpsc::unbounded_channel();
|
||||
|
||||
|
|
|
@ -32,6 +32,10 @@
|
|||
//! arbiter.stop();
|
||||
//! arbiter.join().unwrap();
|
||||
//! ```
|
||||
//!
|
||||
//! # `io-uring` Support
|
||||
//! There is experimental support for using io-uring with this crate by enabling the
|
||||
//! `io-uring` feature. For now, it is semver exempt.
|
||||
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![allow(clippy::type_complexity)]
|
||||
|
|
|
@ -54,7 +54,6 @@ impl System {
|
|||
let (sys_tx, sys_rx) = mpsc::unbounded_channel();
|
||||
|
||||
let rt = Runtime::from(runtime_factory());
|
||||
|
||||
let sys_arbiter = rt.block_on(async { Arbiter::in_new_system() });
|
||||
let system = System::construct(sys_tx, sys_arbiter.clone());
|
||||
|
||||
|
|
|
@ -328,39 +328,30 @@ fn spawn_local() {
|
|||
}
|
||||
|
||||
#[cfg(all(target_os = "linux", feature = "io-uring"))]
|
||||
mod linux_only {
|
||||
use std::sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
};
|
||||
#[test]
|
||||
fn tokio_uring_arbiter() {
|
||||
let system = System::new();
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
|
||||
use super::*;
|
||||
Arbiter::new().spawn(async move {
|
||||
let handle = actix_rt::spawn(async move {
|
||||
let f = tokio_uring::fs::File::create("test.txt").await.unwrap();
|
||||
let buf = b"Hello World!";
|
||||
|
||||
#[test]
|
||||
fn tokio_uring_arbiter() {
|
||||
let system = System::new();
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
let (res, _) = f.write_at(&buf[..], 0).await;
|
||||
assert!(res.is_ok());
|
||||
|
||||
Arbiter::new().spawn(async move {
|
||||
let handle = actix_rt::spawn(async move {
|
||||
let f = tokio_uring::fs::File::create("test.txt").await.unwrap();
|
||||
let buf = b"Hello World!";
|
||||
f.sync_all().await.unwrap();
|
||||
f.close().await.unwrap();
|
||||
|
||||
let (res, _) = f.write_at(&buf[..], 0).await;
|
||||
assert!(res.is_ok());
|
||||
|
||||
f.sync_all().await.unwrap();
|
||||
f.close().await.unwrap();
|
||||
|
||||
std::fs::remove_file("test.txt").unwrap();
|
||||
});
|
||||
|
||||
handle.await.unwrap();
|
||||
tx.send(true).unwrap();
|
||||
std::fs::remove_file("test.txt").unwrap();
|
||||
});
|
||||
|
||||
assert!(rx.recv().unwrap());
|
||||
handle.await.unwrap();
|
||||
tx.send(true).unwrap();
|
||||
});
|
||||
|
||||
drop(system);
|
||||
}
|
||||
assert!(rx.recv().unwrap());
|
||||
|
||||
drop(system);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
## Unreleased - 2021-xx-xx
|
||||
* Remove `config` module. `ServiceConfig`, `ServiceRuntime` public types are removed due to this change. [#349]
|
||||
* Remove `ServerBuilder::configure` [#349]
|
||||
* Add `io-uring` feature for enabling async file Io on linux system. [#374]
|
||||
* Add `io-uring` feature for enabling async file I/O on linux. [#374]
|
||||
|
||||
[#349]: https://github.com/actix/actix-net/pull/349
|
||||
[#374]: https://github.com/actix/actix-net/pull/374
|
||||
|
|
Loading…
Reference in New Issue