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