File: deadlockless.rs

package info (click to toggle)
rust-async-backtrace 0.2.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 252 kB
  • sloc: makefile: 2
file content (37 lines) | stat: -rw-r--r-- 930 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/// A test that a non-blocking taskdump will not deadlock, even if requested
/// from insided a framed future that spawns a scoped thread that requests the
/// task dump.
mod util;
use async_backtrace::framed;

#[framed]
fn deadlockless() {
    util::model(|| util::run(outer()))
}

#[framed]
async fn outer() {
    let dump = std::thread::spawn(|| async_backtrace::taskdump_tree(true))
        .join()
        .unwrap();
    pretty_assertions::assert_str_eq!(
        util::strip(dump),
        "\
╼ deadlockless::outer at backtrace/tests/deadlockless.rs:LINE:COL
  └┈ [POLLING]"
    );
    inner().await;
}

#[framed]
async fn inner() {
    let dump = util::thread::spawn(|| async_backtrace::taskdump_tree(true))
        .join()
        .unwrap();
    pretty_assertions::assert_str_eq!(
        util::strip(dump),
        "\
╼ deadlockless::outer at backtrace/tests/deadlockless.rs:LINE:COL
  └┈ [POLLING]"
    );
}