wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
SimulationBlocker.cpp
Go to the documentation of this file.
1// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
2// SPDX-License-Identifier: GPL-3.0-or-later
3
5
6#include "App/Core/Common.h"
8
10 : m_simulation(simulation)
11{
12 qCDebug(zero) << "Stopping.";
13
14 // Only flag for restart if the simulation was actually running — avoids
15 // accidentally starting a simulation that was intentionally paused.
16 if (m_simulation->isRunning()) {
17 m_restart = true;
18 m_simulation->stop();
19 }
20}
21
23{
24 qCDebug(zero) << "Releasing.";
25
26 // RAII resume: restores the timer exactly when the blocking scope exits,
27 // even if an exception was thrown during the blocked operation.
28 if (m_restart) {
29 m_simulation->start();
30 }
31}
Common logging utilities, the Pandaception error type, and helper macros.
#define qCDebug(category)
Definition Common.h:29
RAII guard that temporarily stops the simulation while in scope.
Synchronous cycle-based simulation engine with event-driven clock support.
SimulationBlocker(Simulation *simulation)
Stops simulation if it was running and records whether to restart.
~SimulationBlocker()
Restarts the simulation if it was running when this blocker was created.
Manages the digital circuit simulation loop.
Definition Simulation.h:38