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