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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: CI
on:
push:
branches:
pull_request:
branches:
permissions:
contents: read
jobs:
test:
name: Test - ${{ matrix.os }} / ${{ matrix.rust }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
rust:
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master
with:
toolchain: ${{ matrix.rust }}
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --all-features --verbose
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
components: clippy
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
bench:
name: Benchmark Compilation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Check benchmarks compile
run: cargo bench --no-run
# The 0.6.0 rewrite shrank the unsafe surface (task allocation and
# waker synchronisation moved into `async-task`, which carries its
# own miri + loom coverage upstream), but it introduced a new
# first-party concurrency protocol — the arm-then-rescan park
# handshake in `src/queue.rs`. The remaining first-party `unsafe`
# is `Builder::spawn_unchecked` in `Threadpool::spawn_local`, whose
# soundness relies on `SpawnFuture::drop` blocking until the
# runnable stops. The jobs below cover both:
#
# * `miri` runs the async-task smoke tests and the crate's unit
# tests under MIRI to catch UB on the `spawn_unchecked` boundary
# and the `Runnable` cross-thread transfer.
# * `loom` runs a model of the queue's parking handshake
# (`tests/loom_queue.rs`) that exhaustively explores producer/
# worker interleavings against the protocol described in
# `src/queue.rs`.
miri:
name: Miri
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Rust nightly with Miri
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master
with:
toolchain: nightly
components: miri
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Run Miri
env:
# `-Zmiri-disable-isolation` lets thread-local time/CPU
# queries used by `async-task` and the test harness succeed
# without external syscalls.
MIRIFLAGS: "-Zmiri-disable-isolation"
# Scope: the `async_task_smoke` integration suite exercises
# the `spawn_unchecked` lifetime contract and the `Runnable`
# send-across-thread path that the new design depends on;
# `--lib` picks up the small set of crate-internal unit
# tests. The full `threadpool_tests` suite uses a tokio
# multi-thread runtime that is impractical under miri.
run: |
cargo miri test --lib
cargo miri test --test async_task_smoke
loom:
name: Loom
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Run Loom models
env:
RUSTFLAGS: "--cfg loom"
LOOM_MAX_PREEMPTIONS: "3"
run: cargo test --release --test loom_queue
# `tests/unsound.rs` is an executable demonstration of the
# `spawn_local` leak-unsoundness (see its module docs). It exercises
# undefined behaviour on purpose, so its result is not guaranteed:
# it usually "passes" because the freed stack slot still reads back as
# a valid integer, but it could fault on some toolchain/platform. We
# therefore RUN it (so the demonstration cannot silently rot or stop
# compiling) but mark the whole job `continue-on-error` so a failure
# never blocks CI. The test is `#[ignore]`d, so the normal `test` jobs
# skip it; this job runs it explicitly with `--ignored`.
unsound:
name: Unsoundness demo (non-blocking)
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Run the unsoundness demonstration (non-blocking)
run: cargo test --test unsound -- --ignored --nocapture