Feature idea: TTHread modification lazarus / 64-FPC development ---------------------------------------------------------------------- kealon · 2015-05-21 16:05 Hi, All May be call of Terminate from TThread.Destroy  move to BeforeDestruction method? ---------------------------------------------------------------------- BitBangerUSA · 2015-05-21 16:51 are you saying that the thread code has a flaw/problem/programming error? perhaps there is a native, human language problem. if you are requesting a feature, you should use the correct Bugtracker link over on the left of the screen. ---------------------------------------------------------------------- taazz · 2015-05-21 16:59 actually the request is pretty clear to me he wants to move the  Terminate method call from destroy to OnBeforeDestruction method for some reason that is not clear to me. I think that hes intention is to discuss the feature but with out any details on the PROs and CONs of the change there is no way I could agree or disagree with the request it is simple insignificant. ---------------------------------------------------------------------- BitBangerUSA · 2015-05-21 17:02 @taazz - yeah, i kind of got that. but i was trying - perhaps poorly - to prompt him for more info. ---------------------------------------------------------------------- kealon · 2015-05-21 19:06 this is proposal to improve some Code Code: [Select]procedure TM.Execute; begin   repeat     Evnt.Wait(Infinite);     if Terminated then break;   ... end; destructor TM.Destroy; begin   Terminate;  // -   if Assigned(Evnt) then Evnt.SetEvent();   inherited Destroy; end;  Terminated variable has False value in Destructor before call inherited destructor I think is no good  because the current mechanism is very ugly ---------------------------------------------------------------------- taazz · 2015-05-21 19:21 Quote from: kealon on May 21, 2015, 09:06:57 pmthis is proposal to improve some Code Code: [Select]procedure TM.Execute; begin   repeat     Evnt.Wait(Infinite);     if Terminated then break;   ... end; destructor TM.Destroy; begin   Terminate;  // -   if Assigned(Evnt) then Evnt.SetEvent();   inherited Destroy; end;  Terminated variable has False value in Destructor before call inherited destructor I think is no good  because the current mechanism is very ugly and it is undefined after you call the inherited destructor but it makes no difference what is the value of terminated. If the execution process entered your destructor then you have to clean up after your self and continue. It is the way that threads are designed and it makes sense, the terminated will be false if the tthread is destroyed either by calling the free method or exiting the execute method and it will be true if someone set it to true to force an exit of the execute method. What do you try to monitor that makes things so ugly for you? ---------------------------------------------------------------------- kealon · 2015-05-22 03:35 QuoteIf the execution process entered your destructor then you have to clean up after your self and continue. Creating in constructor, freeing in destructor  -  it's right but it's a difficult problem in TThread, because some fields of object may be in use I understand that the transfer would not solve the problem completely but I think that the current implementation is the source of the problem ---------------------------------------------------------------------- taazz · 2015-05-22 06:38 Quote from: kealon on May 22, 2015, 05:35:21 amQuoteIf the execution process entered your destructor then you have to clean up after your self and continue. Creating in constructor, freeing in destructor  -  it's right but it's a difficult problem in TThread, because some fields of object may be in use I understand that the transfer would not solve the problem completely but I think that the current implementation is the source of the problem what problem?