diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d5e6de..ba64d9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,7 @@ jobs: - name: Test shell: bash - run: ctest --test-dir build --output-on-failure + run: ./build/tests/tests - name: Upload build artifacts if: always() diff --git a/asco/core/task/cycle_scheduler.h b/asco/core/task/cycle_scheduler.h index d926329..44abb8b 100644 --- a/asco/core/task/cycle_scheduler.h +++ b/asco/core/task/cycle_scheduler.h @@ -35,6 +35,7 @@ class cycle_scheduler : public scheduler { m_scheduler->m_active_count--; m_scheduler->m_domain->suspend_execution(state.id); } else { + state.preawaken = false; m_scheduler->m_domain->activate_execution(state.id); } state.suspend_now = false; @@ -74,6 +75,7 @@ class cycle_scheduler : public scheduler { asco_assert(!state.active); state.detached = true; state.id = execution_id{}; + m_execution_index_map[p.second] = {execution_id{}, -1}; m_detached_count++; break; } @@ -84,6 +86,9 @@ class cycle_scheduler : public scheduler { for (auto &p : m_execution_index_map) { if (p.first == id) { auto &state = m_executions[p.second]; + if (state.detached) { + break; + } if (!state.active) { state.suspend_now = false; state.active = true; @@ -92,7 +97,7 @@ class cycle_scheduler : public scheduler { } else { state.preawaken = true; } - break; + return; } } @@ -107,6 +112,9 @@ class cycle_scheduler : public scheduler { for (auto &p : m_execution_index_map) { if (p.first == id) { auto &state = m_executions[p.second]; + if (state.detached) { + break; + } if (state.preawaken) { state.preawaken = false; break; diff --git a/asco/core/task/dynprio_scheduler.cpp b/asco/core/task/dynprio_scheduler.cpp index 0626162..9f5d45f 100644 --- a/asco/core/task/dynprio_scheduler.cpp +++ b/asco/core/task/dynprio_scheduler.cpp @@ -43,9 +43,9 @@ void dynprio_scheduler::attach_execution(execution_id id) { } void dynprio_scheduler::detach_suspended_execution(execution_id id) { - if (m_suspended_executions.remove(id)) { - m_exec_ctx_map.remove(id); - } + m_suspended_executions.remove(id); + m_exec_ctx_map.remove(id); + m_preawake_executions.remove(id); } void dynprio_scheduler::awake_execution(execution_id id) noexcept {