1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-27 16:52:58 +01:00

add track_caller atrtibute to spawn calls (#454)

* add track_caller attribute to spawn calls

* fix ci
This commit is contained in:
Rob Ede 2022-04-25 21:05:48 +01:00 committed by GitHub
parent dc67ba770d
commit 4c1e581a54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 4 deletions

View File

@ -73,6 +73,14 @@ jobs:
command: install
args: cargo-hack
- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with: { command: generate-lockfile }
- name: Tweak lockfile
run: |
cargo update -p=native-tls --precise=0.2.8
- name: check lib
if: >
matrix.target.os != 'ubuntu-latest'
@ -142,10 +150,9 @@ jobs:
with: { command: generate-lockfile }
- name: Tweak lockfile
uses: actions-rs/cargo@v1
with:
command: update
args: -p=rustls --precise=0.20.2
run: |
cargo update -p=rustls --precise=0.20.2
cargo update -p=native-tls --precise=0.2.8
- name: tests
run: |

View File

@ -1,6 +1,9 @@
# Changes
## Unreleased - 2022-xx-xx
- Add `#[track_caller]` attribute to `spawn` functions and methods. [#454]
[#454]: https://github.com/actix/actix-net/pull/454
## 2.7.0 - 2022-03-08

View File

@ -260,6 +260,7 @@ impl Arbiter {
/// If you require a result, include a response channel in the future.
///
/// Returns true if future was sent successfully and false if the Arbiter has died.
#[track_caller]
pub fn spawn<Fut>(&self, future: Fut) -> bool
where
Fut: Future<Output = ()> + Send + 'static,
@ -275,6 +276,7 @@ impl Arbiter {
/// channel in the function.
///
/// Returns true if function was sent successfully and false if the Arbiter has died.
#[track_caller]
pub fn spawn_fn<F>(&self, f: F) -> bool
where
F: FnOnce() + Send + 'static,

View File

@ -195,6 +195,7 @@ pub mod task {
/// assert!(handle.await.unwrap_err().is_cancelled());
/// # });
/// ```
#[track_caller]
#[inline]
pub fn spawn<Fut>(f: Fut) -> JoinHandle<Fut::Output>
where

View File

@ -53,6 +53,7 @@ impl Runtime {
/// # Panics
/// This function panics if the spawn fails. Failure occurs if the executor is currently at
/// capacity and is unable to spawn a new future.
#[track_caller]
pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
where
F: Future + 'static,
@ -73,6 +74,7 @@ impl Runtime {
///
/// The caller is responsible for ensuring that other spawned futures complete execution by
/// calling `block_on` or `run`.
#[track_caller]
pub fn block_on<F>(&self, f: F) -> F::Output
where
F: Future,

View File

@ -204,6 +204,7 @@ impl SystemRunner {
}
/// Runs the provided future, blocking the current thread until the future completes.
#[track_caller]
#[inline]
pub fn block_on<F: Future>(&self, fut: F) -> F::Output {
self.rt.block_on(fut)