diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9170f22..bc548c6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -159,6 +159,14 @@ jobs: sccache: 'true' manylinux: 2_28 + - name: Install libunwind + if: ${{ matrix.target == 'x86_64-linux-android' }} + run: sudo apt install android-libunwind-dev + + - name: Install libunwind + if: ${{ matrix.target == 'aarch64-linux-android' }} + run: sudo apt install android-libunwind-dev + - name: Add pkg-config files except on MSVC if: ${{ matrix.target != 'x86_64-pc-windows-msvc' }} shell: bash diff --git a/runtime/src/timer.rs b/runtime/src/timer.rs index 841b6a3..a336733 100644 --- a/runtime/src/timer.rs +++ b/runtime/src/timer.rs @@ -92,25 +92,39 @@ impl Timer { loop { if plugins.is_empty() { if let Ok(x) = rx.recv() { - handle!(x) + handle!(x); } } - plugins = plugins - .into_iter() - .filter(|(_k, (engine, end))| { - if let Some(end) = end { - let now = std::time::Instant::now(); - if end <= &now { - engine.increment_epoch(); - return false; + let mut timeout: Option = None; + + plugins.retain(|_k, (engine, end)| { + if let Some(end) = end { + let now = std::time::Instant::now(); + if *end <= now { + engine.increment_epoch(); + return false; + } else { + let time_left = + (*end - now).saturating_sub(std::time::Duration::from_millis(1)); + if let Some(t) = &timeout { + if time_left < *t { + timeout = Some(time_left); + } + } else { + timeout = Some(time_left); } } - true - }) - .collect(); + } - for x in rx.try_iter() { + true + }); + + if let Some(timeout) = timeout { + if let Ok(x) = rx.recv_timeout(timeout) { + handle!(x) + } + } else if let Ok(x) = rx.recv() { handle!(x) } }