PlayaErrorPolling.hpp

00001 // @HEADER
00002 // @HEADER
00003 
00004 #ifndef Playa_ERRORPOLLING_H
00005 #define Playa_ERRORPOLLING_H
00006 
00007 #include "Teuchos_ConfigDefs.hpp"
00008 #include "Teuchos_Assert.hpp"
00009 
00013 
00014 namespace Playa
00015 {
00016   class MPIComm;
00017 
00045   class TEUCHOS_LIB_DLL_EXPORT ErrorPolling
00046   {
00047   public:
00054     static void reportFailure(const MPIComm& comm);
00055     
00062     static bool pollForFailures(const MPIComm& comm);
00063     
00065     static void enable() {isActive()=true;}
00066 
00068     static void disable() {isActive()=false;}
00069 
00070   private:
00072     static bool& isActive() {static bool rtn = true; return rtn;}
00073   };
00074 
00082 #define TEUCHOS_POLL_FOR_FAILURES(comm)                                  \
00083   TEUCHOS_TEST_FOR_EXCEPTION(Playa::ErrorPolling::pollForFailures(comm), \
00084                      std::runtime_error,                                     \
00085                      "off-processor error detected by proc=" << (comm).getRank());
00086 }
00087 
00089 
00090 #endif

doxygen