add Timer::reset_timeout() API, that allows restoring the previous timeout setting after a forced timeout

This commit is contained in:
Axel Kohlmeyer
2016-10-18 12:20:49 -04:00
parent 954d536826
commit 394c3bb504
2 changed files with 7 additions and 1 deletions

View File

@ -95,7 +95,8 @@ Timer::Timer(LAMMPS *lmp) : Pointers(lmp)
{
_level = NORMAL;
_sync = OFF;
_timeout = -1.0;
_timeout = -1;
_s_timeout = -1;
_checkfreq = 10;
_nextcheck = -1;
this->_stamp(RESET);
@ -215,6 +216,7 @@ void Timer::set_wall(enum ttype which, double newtime)
void Timer::init_timeout()
{
_s_timeout = _timeout;
if (_timeout < 0)
_nextcheck = -1;
else

View File

@ -66,6 +66,9 @@ class Timer : protected Pointers {
// trigger enforced timeout
void force_timeout() { _timeout = 0.0; }
// restore original timeout setting after enforce timeout
void reset_timeout() { _timeout = _s_timeout; }
// get remaining time in seconds. 0.0 if inactive, negative if expired
double get_timeout_remain();
@ -91,6 +94,7 @@ class Timer : protected Pointers {
int _level; // level of detail: off=0,loop=1,normal=2,full=3
int _sync; // if nonzero, synchronize tasks before setting the timer
int _timeout; // max allowed wall time in seconds. infinity if negative
int _s_timeout; // copy of timeout for restoring after a forced timeout
int _checkfreq; // frequency of timeout checking
int _nextcheck; // loop number of next timeout check