|
1 | | -use std::pin::pin; |
2 | 1 | use std::sync::{Arc, Mutex, Weak}; |
3 | 2 |
|
4 | 3 | use core_affinity::CoreId; |
5 | | -use futures::FutureExt; |
6 | 4 | use indexmap::IndexMap; |
7 | 5 | use smallvec::SmallVec; |
8 | 6 | use spacetimedb_data_structures::map::HashMap; |
@@ -197,22 +195,20 @@ impl JobCore { |
197 | 195 | }; |
198 | 196 |
|
199 | 197 | let job_loop = async { |
200 | | - let mut closed = pin!(closed.notified().fuse()); |
201 | | - loop { |
202 | | - tokio::select! { |
203 | | - job = rx.recv() => { |
204 | | - let Some(job) = job else { break }; |
205 | | - // blocking in place means that other futures on the same task |
206 | | - // won't get polled - in this case, that's just the repin loop, |
207 | | - // which is fine because it can just run before the next job. |
208 | | - tokio::task::block_in_place(|| job(data)) |
209 | | - } |
210 | | - () = &mut closed => rx.close(), |
211 | | - } |
| 198 | + while let Some(job) = rx.recv().await { |
| 199 | + // blocking in place means that other futures on the same task |
| 200 | + // won't get polled - in this case, that's just the repin loop, |
| 201 | + // which is fine because it can just run before the next job. |
| 202 | + tokio::task::block_in_place(|| job(data)) |
212 | 203 | } |
213 | 204 | }; |
214 | 205 |
|
215 | | - super::also_poll(job_loop, repin_loop).await |
| 206 | + tokio::select! { |
| 207 | + () = super::also_poll(job_loop, repin_loop) => {} |
| 208 | + // when we receive a close notification, we immediately drop all |
| 209 | + // remaining jobs in the queue. |
| 210 | + () = closed.notified() => {} |
| 211 | + } |
216 | 212 | } |
217 | 213 | } |
218 | 214 |
|
|
0 commit comments