OpenFOAM logo
Open Source CFD Toolkit

timer.H File Reference


Detailed Description

View timer.H
License
This file is part of OpenFOAM.

OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.

OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Implements a timeout mechanism. Usage is as following:

timer myTimer(5);     // 5 sec
..
if (timedOut(myTimer))
{
    // timed out
}
else
{
    // do something possible blocking
}

Constructor set signal handler on sigalarm and alarm(). Destructor
clears these.

timedOut is macro because setjmp can't be in member function of timer.
?something to do with stack frames.

WARNING: setjmp restores complete register state so including local vars
held in regs. So if in blocking part something gets calced in a stack
based variable make sure it is declared 'volatile'.

Source files

Definition in file timer.H.

Go to the source code of this file.

Namespaces

namespace  Foam

Classes

class  timer

Defines

#define timedOut(x)   (((x).newTimeOut_ > 0) ? setjmp(Foam::timer::envAlarm) : false)


Define Documentation

#define timedOut  )     (((x).newTimeOut_ > 0) ? setjmp(Foam::timer::envAlarm) : false)
 

Definition at line 75 of file timer.H.

For further information go to www.openfoam.org