added try/catch blocks so that we hopefully can bridge

periods where the new general time provides (unexpectedly
considering its advertised benfits) no time at all.
This commit is contained in:
Jeff Hill
2009-05-11 22:50:06 +00:00
parent 20bd4e9b23
commit 8d245ba595
5 changed files with 67 additions and 12 deletions

View File

@@ -173,7 +173,12 @@ extern "C" void epicsShareAPI
extern "C" double epicsShareAPI
epicsTimerQueuePassiveProcess ( epicsTimerQueuePassiveId pQueue )
{
return pQueue->process ( epicsTime::getCurrent() );
try {
return pQueue->process ( epicsTime::getCurrent() );
}
catch ( ... ) {
return 1.0;
}
}
extern "C" epicsTimerId epicsShareAPI epicsTimerQueuePassiveCreateTimer (

View File

@@ -197,7 +197,12 @@ void timer::show ( unsigned int level ) const
}
double delay;
if ( this->curState == statePending || this->curState == stateActive ) {
delay = this->exp - epicsTime::getCurrent();
try {
delay = this->exp - epicsTime::getCurrent();
}
catch ( ... ) {
delay = - DBL_MAX;
}
}
else {
delay = -DBL_MAX;

View File

@@ -156,6 +156,9 @@ private:
void run ();
void reschedule ();
double quantum ();
void _printLastChanceExceptionMessage (
const char * pExceptionTypeName,
const char * pExceptionContext );
epicsTimerQueue & getEpicsTimerQueue ();
timerQueueActive ( const timerQueueActive & );
timerQueueActive & operator = ( const timerQueueActive & );

View File

@@ -14,7 +14,8 @@
* 505 665 1831
*/
#include <stdio.h>
#include <cstdio>
#include <cfloat>
#define epicsExportSharedSymbols
#include "epicsGuard.h"
@@ -46,13 +47,22 @@ timerQueue::~timerQueue ()
void timerQueue ::
printExceptMsg ( const char * pName, const type_info & type )
{
epicsTime cur = epicsTime :: getCurrent ();
double delay = cur - this->exceptMsgTimeStamp;
if ( delay >= exceptMsgMinPeriod ) {
this->exceptMsgTimeStamp = cur;
char date[64];
char date[64];
double delay;
try {
epicsTime cur = epicsTime :: getCurrent ();
delay = cur - this->exceptMsgTimeStamp;
cur.strftime ( date, sizeof ( date ),
"%a %b %d %Y %H:%M:%S.%f" );
if ( delay >= exceptMsgMinPeriod ) {
this->exceptMsgTimeStamp = cur;
}
}
catch ( ... ) {
delay = DBL_MAX;
strcpy ( date, "UKN DATE" );
}
if ( delay >= exceptMsgMinPeriod ) {
// we dont touch the typeid for the timer expiration
// notify interface here because they might have
// destroyed the timer during its callback

View File

@@ -18,6 +18,7 @@
#define epicsExportSharedSymbols
#include "timerPrivate.h"
#include "errlog.h"
#ifdef _MSC_VER
# pragma warning ( push )
@@ -63,13 +64,44 @@ timerQueueActive::~timerQueueActive ()
this->exitEvent.signal ();
}
void timerQueueActive::run ()
void timerQueueActive :: _printLastChanceExceptionMessage (
const char * pExceptionTypeName,
const char * pExceptionContext )
{
char date[64];
try {
epicsTime cur = epicsTime :: getCurrent ();
cur.strftime ( date, sizeof ( date ), "%a %b %d %Y %H:%M:%S.%f");
}
catch ( ... ) {
strcpy ( date, "<UKN DATE>" );
}
errlogPrintf (
"timerQueueActive: Unexpected C++ exception \"%s\" with type \"%s\" "
"while processing timer queue, at %s\n",
pExceptionContext, pExceptionTypeName, date );
}
void timerQueueActive :: run ()
{
this->exitFlag = false;
while ( ! this->terminateFlag ) {
double delay = this->queue.process ( epicsTime::getCurrent() );
debugPrintf ( ( "timer thread sleeping for %g sec (max)\n", delay ) );
this->rescheduleEvent.wait ( delay );
try {
double delay = this->queue.process ( epicsTime::getCurrent() );
debugPrintf ( ( "timer thread sleeping for %g sec (max)\n", delay ) );
this->rescheduleEvent.wait ( delay );
}
catch ( std :: exception & except ) {
_printLastChanceExceptionMessage (
typeid ( except ).name (), except.what () );
epicsThreadSleep ( 10.0 );
}
catch ( ... ) {
_printLastChanceExceptionMessage (
"catch ( ... )", "Non-standard C++ exception" );
epicsThreadSleep ( 10.0 );
}
}
this->exitFlag = true;
this->exitEvent.signal (); // no access to queue after exitEvent signal