Compare commits

...

7 Commits

Author SHA1 Message Date
Gerd Zellweger fffcd6ca40
Merge 192d0661e9 into bdb56a838d 2026-01-09 18:50:25 +08:00
dependabot[bot] bdb56a838d
build(deps): bump mio from 1.1.0 to 1.1.1 (#774)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-13 12:54:39 +00:00
dependabot[bot] 18aeb3e0ed
build(deps): bump taiki-e/install-action from 2.62.49 to 2.62.57 (#767)
Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.62.49 to 2.62.57.
- [Release notes](https://github.com/taiki-e/install-action/releases)
- [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/taiki-e/install-action/compare/v2.62.49...v2.62.57)

---
updated-dependencies:
- dependency-name: taiki-e/install-action
  dependency-version: 2.62.57
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-26 16:41:26 +00:00
dependabot[bot] f64d5495ae
build(deps): bump actions/checkout from 5 to 6 (#768)
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-26 16:41:15 +00:00
dependabot[bot] b73cf76974
build(deps): bump syn from 2.0.110 to 2.0.111 (#769)
Bumps [syn](https://github.com/dtolnay/syn) from 2.0.110 to 2.0.111.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/2.0.110...2.0.111)

---
updated-dependencies:
- dependency-name: syn
  dependency-version: 2.0.111
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-26 16:40:58 +00:00
dependabot[bot] 17a7718585
build(deps): bump bytes from 1.10.1 to 1.11.0 (#770)
Bumps [bytes](https://github.com/tokio-rs/bytes) from 1.10.1 to 1.11.0.
- [Release notes](https://github.com/tokio-rs/bytes/releases)
- [Changelog](https://github.com/tokio-rs/bytes/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/bytes/compare/v1.10.1...v1.11.0)

---
updated-dependencies:
- dependency-name: bytes
  dependency-version: 1.11.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-26 16:40:49 +00:00
Gerd Zellweger 192d0661e9 Change with_tokio_rt to accept Arc<Runtime>.
This allows to share tokio runtimes across different sub-systems
inside your application.

Signed-off-by: Gerd Zellweger <mail@gerdzellweger.com>
2024-09-04 15:08:47 -07:00
11 changed files with 44 additions and 32 deletions

View File

@ -35,7 +35,7 @@ jobs:
if: matrix.target.os == 'macos-latest'
run: sudo ifconfig lo0 alias 127.0.0.3
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Free Disk Space
if: matrix.target.os == 'ubuntu-latest'
@ -64,7 +64,7 @@ jobs:
toolchain: ${{ matrix.version }}
- name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean
uses: taiki-e/install-action@v2.62.49
uses: taiki-e/install-action@v2.62.57
with:
tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean
@ -113,7 +113,7 @@ jobs:
name: minimal versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Install Rust (nightly)
uses: actions-rust-lang/setup-rust-toolchain@v1.15.2
@ -121,7 +121,7 @@ jobs:
toolchain: nightly
- name: Install cargo-hack & cargo-minimal-versions
uses: taiki-e/install-action@v2.62.49
uses: taiki-e/install-action@v2.62.57
with:
tool: cargo-hack,cargo-minimal-versions

View File

@ -44,7 +44,7 @@ jobs:
if: matrix.target.os == 'macos-latest'
run: sudo ifconfig lo0 alias 127.0.0.3
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Free Disk Space
if: matrix.target.os == 'ubuntu-latest'
@ -73,7 +73,7 @@ jobs:
toolchain: ${{ matrix.version.version }}
- name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean
uses: taiki-e/install-action@v2.62.49
uses: taiki-e/install-action@v2.62.57
with:
tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean
@ -117,7 +117,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Install Rust (nightly)
uses: actions-rust-lang/setup-rust-toolchain@v1.15.2
@ -125,7 +125,7 @@ jobs:
toolchain: nightly
- name: Install just
uses: taiki-e/install-action@v2.62.49
uses: taiki-e/install-action@v2.62.57
with:
tool: just

View File

@ -15,7 +15,7 @@ jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1.15.2
@ -23,7 +23,7 @@ jobs:
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@v2.62.49
uses: taiki-e/install-action@v2.62.57
with:
tool: cargo-llvm-cov

View File

@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions-rust-lang/setup-rust-toolchain@v1.15.2
with:
@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions-rust-lang/setup-rust-toolchain@v1.15.2
with: { components: clippy }
@ -48,7 +48,7 @@ jobs:
if: false # rustdoc mismatch currently
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Install Rust (${{ vars.RUST_VERSION_EXTERNAL_TYPES }})
uses: actions-rust-lang/setup-rust-toolchain@v1.15.2
@ -56,7 +56,7 @@ jobs:
toolchain: ${{ vars.RUST_VERSION_EXTERNAL_TYPES }}
- name: Install just
uses: taiki-e/install-action@v2.62.49
uses: taiki-e/install-action@v2.62.57
with:
tool: just

16
Cargo.lock generated
View File

@ -289,9 +289,9 @@ checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
[[package]]
name = "bytes"
version = "1.10.1"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3"
[[package]]
name = "bytestring"
@ -1079,9 +1079,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.175"
version = "0.2.178"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
[[package]]
name = "libloading"
@ -1178,9 +1178,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "mio"
version = "1.1.0"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873"
checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc"
dependencies = [
"libc",
"log",
@ -2054,9 +2054,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "syn"
version = "2.0.110"
version = "2.0.111"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea"
checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87"
dependencies = [
"proc-macro2",
"quote",

View File

@ -10,6 +10,7 @@ fn main() {
.worker_threads(2)
.enable_all()
.build()
.map(std::sync::Arc::new)
.unwrap()
})
.block_on(async_main());

View File

@ -109,7 +109,7 @@ impl Arbiter {
#[cfg(not(all(target_os = "linux", feature = "io-uring")))]
pub fn with_tokio_rt<F>(runtime_factory: F) -> Arbiter
where
F: FnOnce() -> tokio::runtime::Runtime + Send + 'static,
F: FnOnce() -> std::sync::Arc<tokio::runtime::Runtime> + Send + 'static,
{
let sys = System::current();
let system_id = sys.id();

View File

@ -1,5 +1,4 @@
use std::{future::Future, io};
use std::{sync::Arc, future::Future, io};
use tokio::task::{JoinHandle, LocalSet};
/// A Tokio-based runtime proxy.
@ -9,14 +8,14 @@ use tokio::task::{JoinHandle, LocalSet};
#[derive(Debug)]
pub struct Runtime {
local: LocalSet,
rt: tokio::runtime::Runtime,
rt: Arc<tokio::runtime::Runtime>,
}
pub(crate) fn default_tokio_runtime() -> io::Result<tokio::runtime::Runtime> {
pub(crate) fn default_tokio_runtime() -> io::Result<Arc<tokio::runtime::Runtime>> {
tokio::runtime::Builder::new_current_thread()
.enable_io()
.enable_time()
.build()
.build().map(Arc::new)
}
impl Runtime {
@ -141,6 +140,15 @@ impl Runtime {
impl From<tokio::runtime::Runtime> for Runtime {
fn from(rt: tokio::runtime::Runtime) -> Self {
Self {
local: LocalSet::new(),
rt: Arc::new(rt),
}
}
}
impl From<Arc<tokio::runtime::Runtime>> for Runtime {
fn from(rt: Arc<tokio::runtime::Runtime>) -> Self {
Self {
local: LocalSet::new(),
rt,

View File

@ -5,9 +5,9 @@ use std::{
io,
pin::Pin,
sync::atomic::{AtomicUsize, Ordering},
sync::Arc,
task::{Context, Poll},
};
use futures_core::ready;
use tokio::sync::{mpsc, oneshot};
@ -48,7 +48,7 @@ impl System {
/// [tokio-runtime]: tokio::runtime::Runtime
pub fn with_tokio_rt<F>(runtime_factory: F) -> SystemRunner
where
F: FnOnce() -> tokio::runtime::Runtime,
F: FnOnce() -> Arc<tokio::runtime::Runtime>,
{
let (stop_tx, stop_rx) = oneshot::channel();
let (sys_tx, sys_rx) = mpsc::unbounded_channel();
@ -87,7 +87,7 @@ impl System {
#[doc(hidden)]
pub fn with_tokio_rt<F>(_: F) -> SystemRunner
where
F: FnOnce() -> tokio::runtime::Runtime,
F: FnOnce() -> Arc<tokio::runtime::Runtime>,
{
unimplemented!("System::with_tokio_rt is not implemented for io-uring feature yet")
}

View File

@ -8,7 +8,7 @@ use std::{
use actix_rt::{task::JoinError, Arbiter, System};
#[cfg(not(feature = "io-uring"))]
use {
std::{sync::mpsc::channel, thread},
std::{sync::Arc, sync::mpsc::channel, thread},
tokio::sync::oneshot,
};
@ -252,6 +252,7 @@ fn new_system_with_tokio() {
.on_thread_start(|| {})
.on_thread_stop(|| {})
.build()
.map(Arc::new)
.unwrap()
})
.block_on(async {
@ -284,6 +285,7 @@ fn new_arbiter_with_tokio() {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.map(Arc::new)
.unwrap()
});

View File

@ -425,6 +425,7 @@ impl ServerWorker {
.enable_all()
.max_blocking_threads(config.max_blocking_threads)
.build()
.map(Arc::new)
.unwrap()
})
};