1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-30 17:44:34 +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 command: install
args: cargo-hack 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 - name: check lib
if: > if: >
matrix.target.os != 'ubuntu-latest' matrix.target.os != 'ubuntu-latest'
@ -142,10 +150,9 @@ jobs:
with: { command: generate-lockfile } with: { command: generate-lockfile }
- name: Tweak lockfile - name: Tweak lockfile
uses: actions-rs/cargo@v1 run: |
with: cargo update -p=rustls --precise=0.20.2
command: update cargo update -p=native-tls --precise=0.2.8
args: -p=rustls --precise=0.20.2
- name: tests - name: tests
run: | run: |

View File

@ -1,6 +1,9 @@
# Changes # Changes
## Unreleased - 2022-xx-xx ## 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 ## 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. /// 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. /// Returns true if future was sent successfully and false if the Arbiter has died.
#[track_caller]
pub fn spawn<Fut>(&self, future: Fut) -> bool pub fn spawn<Fut>(&self, future: Fut) -> bool
where where
Fut: Future<Output = ()> + Send + 'static, Fut: Future<Output = ()> + Send + 'static,
@ -275,6 +276,7 @@ impl Arbiter {
/// channel in the function. /// channel in the function.
/// ///
/// Returns true if function was sent successfully and false if the Arbiter has died. /// 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 pub fn spawn_fn<F>(&self, f: F) -> bool
where where
F: FnOnce() + Send + 'static, F: FnOnce() + Send + 'static,

View File

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

View File

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

View File

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