Loading src/TNL/Solvers/SolverMonitor.h +21 −11 Original line number Diff line number Diff line Loading @@ -21,14 +21,12 @@ namespace Solvers { class SolverMonitor { public: SolverMonitor() : timeout_milliseconds( 500 ), stopped(true), started( false ), stopped( false ), timer( nullptr ) {}; ~SolverMonitor() {}; {} virtual void refresh( bool force = false ) = 0; Loading @@ -44,7 +42,11 @@ class SolverMonitor void runMainLoop() { stopped = false; // We need to use both 'started' and 'stopped' to avoid a deadlock // when the loop thread runs this method delayed after the // SolverMonitorThread's destructor has already called stopMainLoop() // from the main thread. started = true; const int timeout_base = 100; const std::chrono::milliseconds timeout( timeout_base ); Loading @@ -62,6 +64,10 @@ class SolverMonitor std::this_thread::sleep_for( timeout ); } } // reset to initial state started = false; stopped = false; } void stopMainLoop() Loading @@ -69,8 +75,12 @@ class SolverMonitor stopped = true; } protected: bool isStopped() const { return stopped; } protected: double getElapsedTime() { if( ! timer ) Loading @@ -80,6 +90,7 @@ class SolverMonitor std::atomic_int timeout_milliseconds; std::atomic_bool started; std::atomic_bool stopped; Timer* timer; Loading Loading @@ -111,4 +122,3 @@ class SolverMonitorThread } // namespace Solvers } // namespace TNL Loading
src/TNL/Solvers/SolverMonitor.h +21 −11 Original line number Diff line number Diff line Loading @@ -21,14 +21,12 @@ namespace Solvers { class SolverMonitor { public: SolverMonitor() : timeout_milliseconds( 500 ), stopped(true), started( false ), stopped( false ), timer( nullptr ) {}; ~SolverMonitor() {}; {} virtual void refresh( bool force = false ) = 0; Loading @@ -44,7 +42,11 @@ class SolverMonitor void runMainLoop() { stopped = false; // We need to use both 'started' and 'stopped' to avoid a deadlock // when the loop thread runs this method delayed after the // SolverMonitorThread's destructor has already called stopMainLoop() // from the main thread. started = true; const int timeout_base = 100; const std::chrono::milliseconds timeout( timeout_base ); Loading @@ -62,6 +64,10 @@ class SolverMonitor std::this_thread::sleep_for( timeout ); } } // reset to initial state started = false; stopped = false; } void stopMainLoop() Loading @@ -69,8 +75,12 @@ class SolverMonitor stopped = true; } protected: bool isStopped() const { return stopped; } protected: double getElapsedTime() { if( ! timer ) Loading @@ -80,6 +90,7 @@ class SolverMonitor std::atomic_int timeout_milliseconds; std::atomic_bool started; std::atomic_bool stopped; Timer* timer; Loading Loading @@ -111,4 +122,3 @@ class SolverMonitorThread } // namespace Solvers } // namespace TNL