Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4ReplaceException.h"
00015
00016 #include "TThread.h"
00017
00018 #include "TGo4Log.h"
00019 #include "TGo4Thread.h"
00020 #include "TGo4ThreadManager.h"
00021 #include "TGo4ThreadHandler.h"
00022 #include "TGo4Runnable.h"
00023
00024 TGo4ReplaceException::TGo4ReplaceException(const TGo4ReplaceException &right)
00025 :TGo4ThreadException(right)
00026 {
00027 GO4TRACE((14,"TGo4ReplaceException::TGo4ReplaceException() copy constructor",__LINE__, __FILE__));
00028 fxNewRunnable=right.fxNewRunnable;
00029 }
00030
00031 TGo4ReplaceException::TGo4ReplaceException (TGo4Runnable* runnable, TGo4Runnable* newrunnable, const char* oldthreadname)
00032 :TGo4ThreadException(runnable, oldthreadname)
00033 {
00034 GO4TRACE((14,"TGo4ReplaceException::TGo4ReplaceException(TGo4Runnable*,TGo4Runnable*,const char*) constructor",__LINE__, __FILE__));
00035 fxDescription= "!!!-- Go4 Replace Exception --!!!";
00036 if(newrunnable==0)
00037 {
00038 GO4TRACE((13,"TGo4ReplaceException constructor -- new runnable same as old runnable",__LINE__, __FILE__));
00039 fxNewRunnable=(TGo4Runnable*) runnable->Clone();
00040 *fxNewRunnable=*runnable;
00041
00042 }
00043 else
00044 {
00045 GO4TRACE((13,"TGo4ReplaceException constructor -- new runnable specified",__LINE__, __FILE__));
00046 fxNewRunnable=newrunnable;
00047 }
00048 }
00049
00050
00051 TGo4ReplaceException::~TGo4ReplaceException()
00052 {
00053 GO4TRACE((14,"TGo4ReplaceException::~TGo4ReplaceException() destructor",__LINE__, __FILE__));
00054 }
00055
00056
00057 TGo4ReplaceException & TGo4ReplaceException::operator=(const TGo4ReplaceException &right)
00058 {
00059 GO4TRACE((14,"TGo4ReplaceException::operator=",__LINE__, __FILE__));
00060 if (&right!=this)
00061 {
00062 GO4TRACE((13,"TGo4ReplaceException::operator= processing copy",__LINE__, __FILE__));
00063 TGo4ThreadException::operator=(right);
00064
00065 fxNewRunnable=right.fxNewRunnable;
00066 return *this;
00067 }
00068 else
00069 {
00070
00071 GO4TRACE((13,"TGo4ReplaceException::operator= source and destination objects are identical",__LINE__, __FILE__));
00072 return *this;
00073 }
00074 }
00075
00076 Int_t TGo4ReplaceException::Handle ()
00077 {
00078 GO4TRACE((14,"TGo4ReplaceException::Handle()",__LINE__, __FILE__));
00079
00080 TString name;
00081 if(GetThreadName()==0)
00082
00083 {
00084 GO4TRACE((13,"TGo4ReplaceException::Handle() -- replacing thread associated with runnable",__LINE__, __FILE__));
00085 name = fxRunnable->GetThread()->GetName();
00086 }
00087 else
00088
00089 {
00090 GO4TRACE((13,"TGo4ReplaceException::Handle() -- replacing thread by specified name",__LINE__, __FILE__));
00091 name = GetThreadName();
00092 }
00093
00094
00095 fxThreadHandler->RemoveThread(name.Data());
00096
00097
00098 fxThreadHandler->NewThread(name,fxNewRunnable);
00099 fxThreadHandler->Start(name);
00100
00101 TThread::CancelPoint();
00102 return 0;
00103
00104 }
00105
00106
00107
00108