From 78fc566dc49f429c47047e41f358653a2bdcfe41 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Fri, 14 Aug 2009 16:54:45 +0000 Subject: [PATCH] improved thread creation failure exception diagnostics --- src/libCom/osi/epicsThread.cpp | 17 +++++++++++++++-- src/libCom/osi/epicsThread.h | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/libCom/osi/epicsThread.cpp b/src/libCom/osi/epicsThread.cpp index 6a3f03962..f4ee1f330 100644 --- a/src/libCom/osi/epicsThread.cpp +++ b/src/libCom/osi/epicsThread.cpp @@ -31,7 +31,19 @@ epicsThreadRunable::~epicsThreadRunable () {} void epicsThreadRunable::run () {} void epicsThreadRunable::show ( unsigned int ) const {} - + +class epicsThread :: unableToCreateThread : + public std :: exception { +public: + const char * what () const throw (); +}; + +const char * epicsThread :: + unableToCreateThread :: what () const throw () +{ + return "unable to create thread"; +} + void epicsThread :: printLastChanceExceptionMessage ( const char * pExceptionTypeName, const char * pExceptionContext ) @@ -47,7 +59,8 @@ void epicsThread :: printLastChanceExceptionMessage ( char name [128]; epicsThreadGetName ( this->id, name, sizeof ( name ) ); errlogPrintf ( - "epicsThread: Unexpected C++ exception \"%s\" with type \"%s\" in thread \"%s\" at %s\n", + "epicsThread: Unexpected C++ exception \"%s\" " + "with type \"%s\" in thread \"%s\" at %s\n", pExceptionContext, pExceptionTypeName, name, date ); errlogFlush (); // this should behave as the C++ implementation intends when an diff --git a/src/libCom/osi/epicsThread.h b/src/libCom/osi/epicsThread.h index 05292348b..d86583c6d 100644 --- a/src/libCom/osi/epicsThread.h +++ b/src/libCom/osi/epicsThread.h @@ -159,7 +159,7 @@ public: static void setOkToBlock ( bool isOkToBlock ) throw (); /* exceptions */ - class unableToCreateThread {}; + class unableToCreateThread; private: epicsThreadRunable & runable; epicsThreadId id;